ORE Studio 0.0.4
Loading...
Searching...
No Matches
Classes | Functions | Variables
src.fpml_parser Namespace Reference

Classes

class  CodeList
 
class  CodeListRow
 
class  CodingScheme
 
class  MergedEntity
 

Functions

str get_subject_area (str entity_dir_name)
 
Optional[ET.Element] find_element (ET.Element parent, str local_name)
 
str find_text (ET.Element parent, str local_name, str default='')
 
list[ET.Element] find_all_elements (ET.Element parent, str local_name)
 
CodingScheme parse_coding_scheme (ET.Element root)
 
list[CodeListRowparse_rows (ET.Element root, CodingScheme coding_scheme, str source_file)
 
CodeList parse_xml_file (Path file_path)
 
tuple[str, str] derive_entity_name (str directory_name)
 
MergedEntity process_entity (Path input_dir, str entity_name)
 
dict load_manifest (Path manifest_path)
 
str load_methodology_text (Path methodology_path)
 
 generate_catalog_sql (dict manifest, Path output_path)
 
 generate_methodology_sql (dict manifest, str methodology_text, Path output_path)
 
 generate_coding_schemes_dataset_sql (dict manifest, Path output_path)
 
 generate_dataset_dependency_sql (dict manifest, Path output_path)
 
 generate_fpml_sql (Path output_dir, list[str] dataset_files, list[str] artefact_files)
 
 generate_coding_schemes_sql (list[MergedEntity] entities, Path output_path)
 
 generate_entity_model (MergedEntity entity, Path output_dir)
 
 generate_populate_data (MergedEntity entity, Path output_dir)
 
 main ()
 

Variables

str GCL_NS = '{http://docs.oasis-open.org/codelist/ns/genericode/1.0/}'
 
str DOC_NS = '{http://www.fpml.org/coding-scheme/documentation}'
 
dict NAMESPACES
 
dict ENTITY_SUBJECT_AREA_MAP
 
dict ENTITY_FILE_PATTERNS
 
dict NON_ISO_CURRENCY_ENRICHMENT
 
dict ENTITIES_WITH_SHARED_TABLES
 

Detailed Description

FPML Genericode XML Parser

Parses FPML coding scheme XML files (OASIS Genericode format) and generates:
1. JSON entity models for SQL schema generation
2. SQL populate scripts for reference data
3. Coding scheme entries for dq_coding_schemes_tbl

Usage:
    python fpml_parser.py <input_dir> <output_dir> [--coding-schemes-only]

The parser handles directories with multiple XML files by merging them,
tracking the source coding scheme for each row.

Function Documentation

◆ get_subject_area()

str get_subject_area ( str  entity_dir_name)
Get the subject area for an entity based on its directory name.
Here is the caller graph for this function:

◆ find_element()

Optional[ET.Element] find_element ( ET.Element  parent,
str  local_name 
)
Find element by local name, handling both namespaced and non-namespaced elements.
Here is the caller graph for this function:

◆ find_text()

str find_text ( ET.Element  parent,
str  local_name,
str   default = '' 
)
Find element text by local name.
Here is the caller graph for this function:

◆ find_all_elements()

list[ET.Element] find_all_elements ( ET.Element  parent,
str  local_name 
)
Find all elements by local name.
Here is the caller graph for this function:

◆ parse_coding_scheme()

CodingScheme parse_coding_scheme ( ET.Element  root)
Extract coding scheme metadata from XML root element.
Here is the caller graph for this function:

◆ parse_rows()

list[CodeListRow] parse_rows ( ET.Element  root,
CodingScheme  coding_scheme,
str  source_file 
)
Extract code list rows from XML root element.
Here is the caller graph for this function:

◆ parse_xml_file()

CodeList parse_xml_file ( Path  file_path)
Parse a single FPML XML file.
Here is the caller graph for this function:

◆ derive_entity_name()

tuple[str, str] derive_entity_name ( str  directory_name)
Derive singular and plural entity names from directory name.

Examples:
    party-roles -> (party_role, party_roles)
    business-centres -> (business_centre, business_centres)
    entity-classifications -> (entity_classification, entity_classifications)
Here is the caller graph for this function:

◆ process_entity()

MergedEntity process_entity ( Path  input_dir,
str  entity_name 
)
Process FPML XML files for a given entity from a flat directory.

Uses ENTITY_FILE_PATTERNS to find matching files.
If multiple files exist, merge them tracking each row's source coding scheme.
Here is the caller graph for this function:

◆ load_manifest()

dict load_manifest ( Path  manifest_path)
Load the data manifest JSON file.
Here is the caller graph for this function:

◆ load_methodology_text()

str load_methodology_text ( Path  methodology_path)
Load the methodology text file.
Here is the caller graph for this function:

◆ generate_catalog_sql()

generate_catalog_sql ( dict  manifest,
Path  output_path 
)
Generate SQL file with catalog upsert from manifest.
Here is the caller graph for this function:

◆ generate_methodology_sql()

generate_methodology_sql ( dict  manifest,
str  methodology_text,
Path  output_path 
)
Generate SQL file with methodology upsert from manifest.
Here is the caller graph for this function:

◆ generate_coding_schemes_dataset_sql()

generate_coding_schemes_dataset_sql ( dict  manifest,
Path  output_path 
)
Generate SQL file with coding schemes dataset upsert from manifest.
Here is the caller graph for this function:

◆ generate_dataset_dependency_sql()

generate_dataset_dependency_sql ( dict  manifest,
Path  output_path 
)
Generate SQL file with dataset dependency upserts from manifest.
Here is the caller graph for this function:

◆ generate_fpml_sql()

generate_fpml_sql ( Path  output_dir,
list[str]  dataset_files,
list[str]  artefact_files 
)
Generate populate_fpml.sql master include file with all FPML files in correct order.
Here is the caller graph for this function:

◆ generate_coding_schemes_sql()

generate_coding_schemes_sql ( list[MergedEntity entities,
Path  output_path 
)
Generate SQL file with coding scheme artefact inserts.
Here is the caller graph for this function:

◆ generate_entity_model()

generate_entity_model ( MergedEntity  entity,
Path  output_dir 
)
Generate JSON model file for entity schema generation.
Here is the caller graph for this function:

◆ generate_populate_data()

generate_populate_data ( MergedEntity  entity,
Path  output_dir 
)
Generate JSON data files for populate script generation.

Generates one file per coding scheme/dataset. For entities with multiple
coding schemes, multiple files are created.
Here is the caller graph for this function:

Variable Documentation

◆ NAMESPACES

dict NAMESPACES
Initial value:
1= {
2 'gcl': 'http://docs.oasis-open.org/codelist/ns/genericode/1.0/',
3 'doc': 'http://www.fpml.org/coding-scheme/documentation',
4}

◆ ENTITY_SUBJECT_AREA_MAP

dict ENTITY_SUBJECT_AREA_MAP
Initial value:
1= {
2 # Parties - party identification and classification
3 'party-roles': 'Parties',
4 'person-roles': 'Parties',
5 'party-relationships': 'Parties',
6 'entity-classifications': 'Parties',
7 # Trading - trading infrastructure
8 'account-types': 'Trading',
9 'business-centres': 'Trading',
10 'business-processes': 'Trading',
11 'cashflow-types': 'Trading',
12 # Market Data - asset and benchmark reference
13 'asset-classes': 'Market Data',
14 'asset-measures': 'Market Data',
15 'benchmark-rates': 'Market Data',
16 # Regulatory - regulatory bodies and regimes
17 'local-jurisdictions': 'Regulatory',
18 'regulatory-corporate-sectors': 'Regulatory',
19 'reporting-regimes': 'Regulatory',
20 'supervisory-bodies': 'Regulatory',
21 # Currencies - currency codes
22 'non-iso-currencies': 'Currencies',
23}

◆ ENTITY_FILE_PATTERNS

dict ENTITY_FILE_PATTERNS
Initial value:
1= {
2 'account-types': ['account-type-*.xml'],
3 'asset-classes': ['asset-class-*.xml'],
4 'asset-measures': ['asset-measure-*.xml'],
5 'benchmark-rates': ['benchmark-rate-*.xml'],
6 'business-centres': ['business-center-*.xml'],
7 'business-processes': ['business-process-*.xml'],
8 'cashflow-types': ['cashflow-type-*.xml'],
9 'entity-classifications': ['entity-type-*.xml', 'cftc-entity-classification-*.xml', 'cftc-organization-type-*.xml'],
10 'local-jurisdictions': ['local-jurisdiction-*.xml'],
11 'non-iso-currencies': ['non-iso-currency-*.xml'],
12 'party-relationships': ['party-relationship-type-*.xml', 'hkma-rewrite-party-relationship-type-*.xml'],
13 'party-roles': ['party-role-*.xml'],
14 'person-roles': ['person-role-*.xml'],
15 'regulatory-corporate-sectors': ['regulatory-corporate-sector-*.xml', 'hkma-rewrite-regulatory-corporate-sector-*.xml'],
16 'reporting-regimes': ['reporting-regime-*.xml'],
17 'supervisory-bodies': ['supervisory-body-*.xml'],
18}

◆ ENTITIES_WITH_SHARED_TABLES

dict ENTITIES_WITH_SHARED_TABLES
Initial value:
1= {
2 'non-iso-currencies': {
3 'artefact_type': 'currencies',
4 'artefact_table': 'dq_currencies_artefact_tbl',
5 'production_table': 'refdata_currencies_tbl',
6 'populate_function': 'dq_currencies_publish_fn',
7 'skip_schema_generation': True,
8 }
9}