taxonomy

Since there is a large number of financial information with different accounting systems (us-gaap, ifrs…), a common language framework must be established prior to the data transfer. In the XBRL context, this common language framework is called a Taxonomy. The taxonomy defines a list of concepts that can then be used in the instance document to tag certain numbers and ensures the integrity and syntactic correctness of the data. The taxonomy schema is the heart of the taxonomy and defines the concepts of the taxonomy. The concepts will later be used by the creator of a financial report to tag certain numbers. A Taxonomy schema defines the reportable concepts and links the linkbases to describe the relationships between the concepts. Taxonomy schemas can import multiple different taxonomy schemas.

The current Taxonomy Schema can override the extended schemas in the following way:

1. Addition of new concepts: New concepts are added in this TaxonomySchema to extend the concepts declared in the base Taxonomy schemas

2. Addition of resources: The Label Linkbase of this taxonomy can add new labels to existing concepts from the base taxonomy

3. Overriding of relationships: All Linkbases of this taxonomy can override i.e the order of concepts in a definition linkbase

4. Overriding of resources: The Label Linkbase of this taxonomy can override the labels of the base taxonomy!

read more at: https://manusimidt.dev/2021-07/xbrl-explained

Parser Class

class xbrl.instance.XbrlInstance(url, taxonomy, facts, context_map, unit_map)

Class representing a xbrl instance file

__init__(url, taxonomy, facts, context_map, unit_map)
Parameters
  • taxonomy (TaxonomySchema) – taxonomy file that the instance file references (via link:schemaRef)

  • facts (list[AbstractFact]) – array of all facts that the instance contains

json(file_path=None, override_fact_ids=True, **kwargs)

Converts the instance document into json format :type file_path: Optional[str] :param file_path: if a path is given the function will store the json there :type override_fact_ids: bool :param override_fact_ids: :param kwargs: additional arguments for the json parser :rtype: str | None :return: string (serialized json) or None (if file_path was given)

https://www.xbrl.org/Specification/xbrl-json/REC-2021-10-13/xbrl-json-REC-2021-10-13.html

Parse functions

This module contains all classes and functions necessary for parsing Taxonomy schema files.

Other Classes

class xbrl.taxonomy.Concept(xml_id, schema_url, name)

Class representing a Concept defined in the schema (xs:element) i.e: <xs:element id=’us-gaap_Assets’ name=’Assets’ nillable=’true’ substitutionGroup=’xbrli:item’ type=’xbrli:monetaryItemType’ xbrli:balance=’debit’ xbrli:periodType=’instant’ />

__init__(xml_id, schema_url, name)
Parameters
  • xml_id (str) – Id of the concept in the xml

  • schema_url (str) – url of the schema in which the concept is defined

  • name (str) – name of the concept

to_dict()

Converts the Concept object into a dictionary representation

to_json()

Converts the Concept object into a JSON string

class xbrl.taxonomy.TaxonomySchema(schema_url, namespace)

Class represents a Generic Taxonomy Schema. Since this parser is optimized for EDGAR submission’s, it will only differentiate between the Extending Taxonomy (the taxonomy that comes with the filing) and multiple base Taxonomies (i.e dei, us-gaap, exch, naics, sic …). This parser will not parse all Schemas and imports, only what is necessary.

__init__(schema_url, namespace)

The imports array stores an array of all Schemas that are imported.

Parameters
  • schema_url (str) –

  • namespace (str) –

get_schema_urls(visited=None)

Returns an array of all taxonomy urls that are used by this taxonomy Also includes the schema url of this taxonomy :rtype: list[str] :return:

get_taxonomy(url, visited=None)

Returns the taxonomy with the given namespace (if it is the current taxonomy, or if it is imported) If the taxonomy cannot be found, the function will return None :type url: str :param url: can either be the namespace or the schema url :type visited: Optional[set[str]] :param visited: set of already visited schema urls to prevent infinite recursion :return: either a TaxonomySchema obj or None