XML Instance
The xml-instance module contains all the classes related to XBRL-XML instance files. It contains the attributes Scenario,
Context and Facts.
The main purpose is to extract and classify the data. In the xbrl file, the basic unit is the fact, form by a unique value and its decimals (precision), context and currency.
This facts are grouped by a context. In xbrl files, it is represented with an id, and contains info related to the entity and period where facts belongs to. Also, an attribute named scenario appears related to the context. Its main function is parsing the xml-instance, integrating the dimension of the taxonomy’s variable with the context.
Instance Class
- class xbridge.instance.Instance(path: str | Path | None = None)
Bases:
objectAbstract class representing an XBRL instance file. Its attributes are the characters contained in the XBRL files.
- property base_currency: str | None
Returns the base currency of the instance file
- property entity: str
Returns the entity of the instance file.
- property facts_list_dict: List[Dict[str, Any]] | None
Returns a list of dictionaries with the facts of the instance file.
- property filing_indicators: List[FilingIndicator] | None
Returns the filing indicators of the instance file.
- get_contexts() None
Extracts
Contextfrom the XML instance file.
- get_module_code() None
Extracts the module name from the XML instance file.
- get_units() None
Extracts the base currency of the instance
- property identifier_prefix: str
Returns the identifier prefix of the instance file.
- property instance_df: DataFrame | None
Returns a pandas DataFrame with the facts of the instance file.
- property module_code: str | None
Returns the module name of the instance file.
- property module_ref: str | None
Returns the module reference of the instance file.
- property namespaces: Dict[str | None, str]
Returns the namespaces is of the instance file.
- parse() None
Parses the XML file into the library objects.
- property period: str | None
Returns the period of the instance file
- property table_files: set[Path]
Returns the
TableFiles
- property temp_dir_path: Path | None
- property units: Dict[str, str] | None
Returns the units of the instance file
- validate_entity(context: str) None
Validates that a certain
Contextdoes not add a second entity (i.e., the instance contains data only for one entity).
Scenario Class
- class xbridge.instance.Scenario(scenario_xml: _Element | None = None)
Bases:
objectClass for the scenario of a
Context. It parses the XML node with the scenario created and gets a value that fits with the scenario created from the XML node.- static get_value(child_scenario: _Element) str
Gets the value for dimension from the XML node with the scenario.
- parse() None
Parses the XML node with the scenario
Context Class
- class xbridge.instance.Context(context_xml: _Element)
Bases:
objectContext class.
Class for the context of a fact. Its attributes are id, entity, period and scenario.
Returns a dictionary which has as keys the entity and the period.
- property entity: str
Returns the entity of the
Context.
- property id: str
Returns the id of the
Context.
- parse() None
Parses the XML node with the
Context.
- property period: str
Returns the period of the
Context.
Fact Class
Filing Indicator Class
- class xbridge.instance.FilingIndicator(filing_indicator_xml: _Element)
Bases:
objectClass for the filing indicator of an instance. Returns the filing Indicator value and also a table with a
Context- parse() None
Parse the XML node with the filing indicator.
- Raises:
FilingIndicatorValueError – If the filed attribute is not “true”, “false”, “0”, or “1”