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.xml_instance.Instance(path: str | None = None)
Bases: object
Class representing an XBRL XML instance file. Its attributes are the characters contained in the XBRL files.
Each property returns one of these attributes.
- Parameters:
path – File path to be used
-
property base_currency
Returns the base currency of the instance file
-
property contexts
Returns the Context
of the instance file.
-
property decimals_monetary
Returns the single value for monetary values in the instance.
-
property decimals_percentage
Returns the single value for percentage values in the instance.
-
property entity
Returns the entity of the instance file.
-
property facts
Returns the facts of the instance file.
-
property facts_list_dict
Returns a list of dictionaries with the facts
of the instance file.
-
property filing_indicators
Returns the filing indicators of the instance file.
-
get_contexts()
Extracts Context
from the XML instance file.
-
get_facts()
Extracts facts
from the XML instance file.
-
get_facts_list_dict()
Generates a list of dictionaries with the facts
of the instance file.
-
get_filing_indicators()
Extracts filing
indicators from the XML instance file.
-
get_module_code()
Extracts the module name from the XML instance file.
-
get_units()
Extracts the base currency of the instance
-
property identifier_prefix
Returns the identifier prefix of the instance file.
-
property instance_df
Returns a pandas DataFrame with the facts
of the instance file.
-
property module_code
Returns the module name of the instance file.
-
property module_ref
Returns the module reference of the instance file.
-
property namespaces
Returns the namespaces is of the instance file.
-
parse()
Parses the XML file into the library objects.
-
property period
Returns the period of the instance file
-
to_df()
Generates a pandas DataFrame with the facts
of the instance file.
-
property units
Returns the units of the instance file
-
validate_entity(context)
Validates that a certain Context
does not add a second entity
(i.e., the instance contains data only for one entity).
Scenario Class
-
class xbridge.xml_instance.Scenario(scenario_xml=None)
Bases: object
Class 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)
Gets the value for dimension
from the XML node with the scenario.
-
parse()
Parses the XML node with the scenario
Context Class
-
class xbridge.xml_instance.Context(context_xml)
Bases: object
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
Returns the entity of the Context
.
-
property id
Returns the id of the Context
.
-
parse()
Parses the XML node with the Context
.
-
property period
Returns the period of the Context
.
-
property scenario
Returns the scenario of the Context
.
Fact Class
-
class xbridge.xml_instance.Fact(fact_xml)
Bases: object
Class for the facts
of an instance. Returns the facts of the instance with information such as the value, its decimals, Context
and units.
-
parse()
Parse the XML node with the fact.
Filing Indicator Class
-
class xbridge.xml_instance.FilingIndicator(filing_indicator_xml)
Bases: object
Class for the filing indicator of an instance. Returns the filing Indicator value and also a table with a
Context
-
parse()
Parse the XML node with the filing indicator.