linkbase

Linkbases are individual XML files that bring structure to concepts and link them to additional information. This information can be, for example, user-friendly labels or references to authoritative literature. The linkbases are imported in the taxonomy schema. Linkbases can be divided into two main groups: Relation Linkbases and Reference Linkbases. Relation Linkbases create hierarchical relationships between multiple concepts. The interpretation of these hierarchical relationships is defined by the type of linkbase. Reference linkbases, on the other hand, add resources to concepts.

Relation Linkbases:

Calculation Linkbase: The Calculation Linkbase defines simple arithmetic relationships between individual concepts. If the above example were a calculation linkbase, it would define the following equation: us-gaap_Assets = us-gaap_AssetsCurrent + us-gaap_AssetsNonCurrent.

Presentation Linkbase: The presentation linkbase describes the order in which the concepts of the taxonomy should be arranged. The above example would subordinate the us-gaap_AssetsCurrent and us-gaap_AssetsNonCurrent concepts to the us-gaap_Assets concept.

Definition Linkbase: The definition linkbase allows to create various other logical connections between concepts. For example, a link with the arcrole “essence-alias” can be used to emphasize that two concepts cover the same or very similar subject matter.

Reference Linkbases:

Label Linkbase: The Label Linkbase links concepts with one or more reader-friendly labels. It is also possible to link labels in different languages.

Reference Linkbase: The reference linkbase can be used to create links between concepts and documents outside of XBRL/XML. Most often, these external documents are laws or policies that govern the calculation, disclosure, or presentation of these concepts.

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

Parse functions

linkbase.parse_linkbase_url(linkbase_type, cache)

Parses a linkbase given given a url

Parameters
  • linkbase_url (str) – full link to the linkbase

  • linkbase_type (LinkbaseType) – type of the linkbase (calculation-, label-, presentation-, …)

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

Return type

Linkbase

Returns

parsed xbrl.linkbase.Linkbase object

linkbase.parse_linkbase(linkbase_type, linkbase_url=None)

Parses a linkbase and returns a Linkbase object containing all locators, arcs and links of the linkbase in a hierarchical order (a Tree) A Linkbase usually does not import any additional files. Thus no cache instance is needed

Parameters
  • linkbase_path (str) – path to the linkbase

  • linkbase_type (LinkbaseType) – Type of the linkbase

  • linkbase_url (Optional[str]) – if the locator of the linkbase contain relative references to concepts (i.e.: ‘./../schema.xsd#Assets’) the url has to be set so that the parser can connect the locator with concept from the taxonomy

Return type

Linkbase

Returns

parsed xbrl.linkbase.Linkbase object

Class

class xbrl.linkbase.Linkbase(extended_links, linkbase_type, linkbase_uri=None)

Represents a complete Linkbase (non-generic).

__init__(extended_links, linkbase_type, linkbase_uri=None)
Parameters
  • extended_links ([ExtendedDefinitionLink] or [ExtendedCalculationLink] or [ExtendedPresentationLink] or [ExtendedLabelArc]) – All standard extended links that are defined in the linkbase

  • linkbase_type (LinkbaseType) – Type of the linkbase

  • linkbase_uri (Optional[str]) – Either the path or the url to the linkbase (depends from where the parser loaded it for parsing)

to_dict()

Converts the Linkbase object with in a dictionary representing the Hierarchy of the locators

Return type

dict

to_simple_dict()

Does the same as to_dict() but ignores the ArcElements. So it basically returns the hierarchy, without the information in which type of relationship parent and children are

Return type

dict