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

Parse functions

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

taxonomy.parse_taxonomy_url(cache, imported_schema_uris={})

Parses a taxonomy schema file from the internet

Parameters
  • schema_url (str) – full link to the taxonomy schema

  • cache (HttpCache) – xbrl.cache.HttpCache instance

  • imported_schema_uris (set) – set of already imported schema uris

Return type

TaxonomySchema

Returns

parsed xbrl.taxonomy.TaxonomySchema object

taxonomy.parse_taxonomy(cache, imported_schema_uris, schema_url=None)

Parses a taxonomy schema file.

Parameters
  • schema_path (str) – url to the schema (on the internet)

  • cache (HttpCache) – xbrl.cache.HttpCache instance

  • imported_schema_uris (set) – set of already imported schema uris

  • schema_url (Optional[str]) – if this url is set, the script will try to fetch additionally imported files such as linkbases or imported schemas from the remote location. If this url is None, the script will try to find those resources locally.

Return type

TaxonomySchema

Returns

parsed xbrl.taxonomy.TaxonomySchema object

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

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()

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

get_taxonomy(url)

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 :return: either a TaxonomySchema obj or None