XBRL Template File and XBRLTaxonomy: Difference between pages

From XBRLWiki
(Difference between pages)
Jump to navigationJump to search
 
 
Line 1: Line 1:
==Description==
[[http://www.reportingstandard.com/apidoc/com/ihr/xbrl/om/taxonomy/XBRLTaxonomy.html XBRLTaxonomy javadoc page]]
===Description===
An XBRLTaxonomy object represents the content of an XBRL Taxonomy and the surrounding XML Schema. This is:


The XBRL Template file is an XML file that defines events in order to let drivers to capture data that will be used for the generation of a new XBRL report.
* the Namespace, and
* all XBRL concept definitions (items and tuples) , and
* all XBRL role types locally defined, and
* all XBRL arcrole types locally defined, and
* all references to imported XBRL Taxonomies, and
* all references to external and embedded XBRL Linkbases, and
* all other XML Schema related constructions like global groups, global type declarations, global attribute groups, global attribute declarations and global element declarations that are not XBRL concepts.


The namespace definition of elements in the XBRL Template file is '''<nowiki>http://www.reportingstandard.com/map/3</nowiki>'''
===How to create an instance of an XBRLTaxonomy object===


The official location for the schema that corresponds to the indicated namespace is '''<nowiki>http://www.reportingstandard.com/schemas/mapper/mapper-2011.xsd</nowiki>'''
There are several ways depending on what the user needs are:


==Sample file==
* If the user have just created a new empty [[DTSContainer]] object and the purpose is to read the content of an XBRL taxonomy (and the whole referenced DTS) then the simplest way is to use one of the load methods in the [[DTSContainer]] object passing the document URI of the XBRL taxonomy. The returned object is an XBRLTaxonomy that can be casted to an XBRLTaxonomy.


<syntaxhighlight lang="xml">
* If the user has already loaded a DTS (from another taxonomy file or an XBRL report) and the purpose is to create a new XBRLTaxonomy (in order to create a taxonomy extension) then, the user can use any of the available [[http://www.reportingstandard.com/apidoc/com/ihr/xbrl/om/taxonomy/XBRLTaxonomy.html#constructor_summary constructors]]. The most commonly used constructor is [[http://www.reportingstandard.com/apidoc/com/ihr/xbrl/om/taxonomy/XBRLTaxonomy.html#XBRLTaxonomy(com.ihr.xbrl.om.DTSContainer) XBRLTaxonomy(com.ihr.xbrl.om.DTSContainer)]] that accepts the current DTSContainer as a parameter and allows the user to start adding concepts programatically.
<?xml version="1.0" encoding="UTF-8"?>
<!--
This is a simple configuration file for Reporting Standard XBRL Mapping engine.


(C) Reporting Standard S.L. 2007-2015 - All rights reserved
Creation of a XBRLTaxonomy object from a local file name:
 
<syntaxhighlight lang="java">
This file has been created for the purposes to show a simple use case for the mapper
/**
 
* Sample, a new XBRLTaxonomy document is read form the file received as a parameter
The namespace for this file is "http://www.reportingstandard.com/map/3"
* After the instance object is obtained, the user can start working with it
The "official location" of the schema is "http://www.reportingstandard.com/schemas/mapper/mapper-2011.xsd"
*/
The mapping engine already provides an internal copy of the schema for the purposes of validating the
public class SampleReadTaxonomy {
configuration file. The mapping engine does not need to have interner access.
-->
<xbrlMap
xmlns="http://www.reportingstandard.com/map/3"  
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.reportingstandard.com/map/1 http://www.reportingstandard.com/schemas/mapper/mapper-2011.xsd"
xmlns:xbrli="http://www.xbrl.org/2003/instance"
xmlns:xbrldi="http://xbrl.org/2006/xbrldi">
<!--
section 1. identify the data source drivers that will be used to obtain the data related to this intace document template
there may be more than one data source driver.
each data source driver is identified by its id
the class MUST be in the classpath of the mapping Java Virtual Machine
-->
<datasources>
<source id="source0" class="com.ihr.xbrl.mapper.source.StaticSource"/>
</datasources>
<!--
section 2. this section provides data for the instance template
-->
<instance>
<!--
This is the set of files that compose the DTS of the instance document.
One or more files can be specified here.
The files may be either XBRL 2.1 Schemas or XBRL 2.1 Linkbases
-->
<dts>
<file>taxonomy.xsd</file>
</dts>
<!--
Templates for contexts. Contexts may be overwritten by the data source driver. but default contexts for facts
will be generated using the templates in this section.
-->
<contexts>
<scheme>http://www.xbrl.org/companyName</scheme>
<company>The Sample Company Name</company>
<!--
Template for instant contexts
-->
<context id="ctx0i">
<entity>
<xbrli:identifier scheme="_">_</xbrli:identifier>
</entity>
<period>
<instant>eoy-P1Y</instant>
</period>
</xbrli:context>
<!--
Template for duration contexts
-->
<context id="ctx0d">
<entity>
<xbrli:identifier scheme="_">_</xbrli:identifier>
</entity>
<period>
<startDate>boy-P1Y</startDate>
<endDate>eoy-P1Y</endDate>
</period>
</context>
</contexts>
<!--
Units used by the facts below
-->
<units>
<xbrli:unit id="EUR">
<xbrli:measure xmlns:iso4217="http://www.xbrl.org/2003/iso4217">iso4217:EUR</xbrli:measure>
</xbrli:unit>
</units>
<!--
Template of the instance document to produce
-->
<facts xmlns:tx="http://taxonomy.com/example">
<!-- item -->
<item sourceRef="source0" contextRef="ctx0i" mapIdentifier="identifier0" concept="tx:A" unitRef="EUR"/>
<item sourceRef="source0" contextRef="ctx0d" mapIdentifier="identifier1" concept="tx:B" multi="Single" unitRef="EUR"/>
<!-- tuple -->
<tuple concept="tx:U">
<item sourceRef="source0" contextRef="ctx0d" mapIdentifier="identifier2" concept="tx:C" multi="1"/>
<item sourceRef="source0" contextRef="ctx0d" mapIdentifier="identifier3" concept="tx:D" multi="Single"/>
<item sourceRef="source0" contextRef="ctx0d" mapIdentifier="identifier4" concept="tx:E" multi="All" unitRef="EUR"/>
</tuple>
</facts>
</instance>
</xbrlMap>


  public static void main(String[] args) throws Exception {
    DTSContainer dts = DTSContainer.newEmptyContainer();
    XBRLTaxonomy taxonomy = (XBRLTaxonomy)dts.load(new File(args[0]).toURI());
    // ... rest of the application code goes here
  }
}
</syntaxhighlight>
</syntaxhighlight>


==Elements==
Creation of a new taxonomy document for a DTS after the DTS has been loaded:
<syntaxhighlight lang="java">
/**
* Sample, a new instance document is created after the DTS has been loaded
*/
public class SampleCreateTaxonomyExtension {


The root element is '''xbrlMap'''
  public static void main(String[] args) throws Exception {
    DTSContainer dts = DTSContainer.newEmptyContainer();
    dts.load(new File("sampleTaxonomy.xsd").toURI());


The content of the xbrlMap element is divided in two sections.
    XBRLTaxonomy taxonomy = new XBRLTaxonomy(dts);


* Definition of data sources
    // adds taxonomy default minimum information
* Event definitions and associated metadata
    String targetNamespace = "http://www.reportingstandard.com/samples/2009/newTaxonomy";
    tx.setURI(new URI("taxonomyExtension.xsd"));
    tx.setTargetNamespace(targetNamespace);
    tx.addNamespace("tx", targetNamespace);
    dts.addDocumentToDTS(tx);


Both sections are required in a mapping file and that must occurs only once
    // ... rest of the application code goes here


===Definition of data sources===
    // Save the Taxonomy extension to disk
 
    dts.save(true);
Data sources are defined using '''source''' elements as children of the '''datasources''' element.
  }
}
</syntaxhighlight>


The '''source''' element is an empty element that has three attributes:
===The Namespace===
* Required ''id'' attribute. Used by '''item''' and '''tuple''' events (see next section Definition of Events) in order to identify the data source they are linked with.
* Required ''class'' attribute. Used to indicate the driver class. The driver class must be instantiated at runtime (in a dll or in the classpath) and must implement the interface defined in [http://www.reportingstandard.com/apidoc/com/ihr/xbrl/mapper/source/XBRLDataSource.html the XBRLDataSource interface].
* Optional ''config'' attribute. Used to point to a file with configuration information for the driver indicated in the ''class'' attribute. The content may be a URI relative to the URI of the XBRL Template File and it is resolved using ''xml:base'' if it is indicated in the '''source''' element or any of it ancestors.
 
A sample datasources section where two data sources are defined. One is a web form, the other is a connection to a database that requires a configuration file called SQLMapperDriverConfig.xml and is located in the same folder as the XBRL Template file:
<syntaxhighlight lang="xml">
  <datasources>
    <source id="form" class="com.ihr.xbrl.mapper.source.WebFormDataSource"/>
    <source id="sql" class="com.ihr.xbrl.mapper.source.SQLDataSource" config="SQLMapperDriverConfig.xml"/>
  </datasources>
</syntaxhighlight>


===Definition of events===
XBRL Taxonomies are the containers of concept definitions. Concept definitions must be unique worldwide (assets in the US-GAAP and assets in the IFRS). The mechanism provided by the W3C consortium in order to allow easy distinction between concepts defined in different taxonomies is called namespaces.


The '''xbrlMap''' root element must have an '''instance''' element that in turn contains four sub-sections:
Each taxonomy is an XML Schema. An XML Schema may define a Namespace. The namespace is a unique name that may be of a form of a URI (Unique Resource Identifier).
* The definition of the instance DTS
* The definition of the contexts templates
* The definition of the units
* The definition of the facts (Here is where the real events are defined. The previous three sections are just meta-data in order to facilitate the definition of the events)


====The instance DTS====
For example:
* IFRS 2009 concepts namespace is: <nowiki>http://xbrl.iasb.org/taxonomy/2009-04-01/ifrs</nowiki>
* US-GAAP 2009 concepts namespace is: <nowiki>http://xbrl.us/us-gaap/2009-01-31</nowiki>


The instance DTS defines the schemas and linkbases that will be included in the new XBRL report in '''link:schemaRef''' and '''link:linkbaseRef''' elements. In the template file it is not required distinguishing between linkbase files and schema files. Both will be documented as simple files. The API will detect the file type and will include the required elements in the final XBRL report automatically.
Here is the [[http://www.w3.org/TR/xml-names/ link for the Namespaces specification]] at the W3C consortium.


The first child of the instance element must be a '''dts''' element that, in turn, contains an unlimited number of '''file''' elements each one of them indicating a relative or absolute file that will be included in the instance document during instance document generation phase. It is strongly recommended using official absolute file names of taxonomy or linkbase files in order to produce XBRL reports than can be opened everywhere. If you believe this is against performance, you may know that mapping external files on the Internet to local files is supported by almost all serious XBRL software vendors. Reporting Standard S.L. has implemented this feature using the [[XBRL Catalog]] and providing user friendly tools in order to help maintaining the local taxonomy catalog.
====Read access====
The API call [[http://www.reportingstandard.com/apidoc/com/ihr/xbrl/om/taxonomy/XBRLTaxonomy.html#getTargetNamespace() getTargetNamespace()]] gives direct access to the taxonomy namespace.


This is a sample '''dts''' section definition for the IFRS taxonomy:
====Write access====
<syntaxhighlight lang="xml">
The API call [[http://www.reportingstandard.com/apidoc/com/ihr/xbrl/om/taxonomy/XBRLTaxonomy.html#setTargetNamespace(java.lang.String) setTargetNamespace(String namespace)]] sets or changes the taxonomy namespace.
    <dts>
      <file>http://xbrl.iasb.org/taxonomy/2009-04-01/ifrs/ias_1_2009-04-01/cal_ias_1_2009-04-01_role-210000.xml</file>
      <file>http://xbrl.iasb.org/taxonomy/2009-04-01/ifrs/label/lab_ifrs-en_2009-04-01.xml</file>
      <file>http://xbrl.iasb.org/taxonomy/2009-04-01/ifrs/ias_1_2009-04-01/pre_ias_1_2009-04-01_role-210000.xml</file>
      <file>http://xbrl.iasb.org/taxonomy/2009-04-01/ifrs/ias_1_2009-04-01/def_ias_1_2009-04-01_role-210000.xml</file>
    </dts>
</syntaxhighlight>
Note that this example is not including the IFRS taxonomy schema. This is not an error. The required schema will be added automatically by the tool in order to produce a valid XBRL report during the document creation phase.


====Contexts templates====
===Working with concept definitions===
We can classify XBRL Taxonomies in two categories:
# '''Taxonomies that defines new concepts''': They are XBRL Taxonomies that contains new concept definitions. A concept definition is an element in the ''item'' or ''tuple'' substitution group. Normally, Taxonomies that defines new concepts also include references to the labels and reference linkbases.
# '''Taxonomies that does not define new concepts''': They are XBRL Taxonomies that serves organize the content of the DTS, for example, including a common set of presentation and calculation linkbases together.


The '''contexts''' (in plural) element is a container for context templates. Context templates looks like xbrl contexts but most of the elements are in the namespace defined in the mapper schema rather than the XBRL namespace.
====Read access====
While working with an XBRL Taxonomy, the user may be interested in accessing concepts defined. The XBRLTaxonomy API provides methods for exploring all concept definitions [[http://www.reportingstandard.com/apidoc/com/ihr/xbrl/om/taxonomy/XBRLTaxonomy.html#getConcepts() getConcepts()]], [[http://www.reportingstandard.com/apidoc/com/ihr/xbrl/om/taxonomy/XBRLTaxonomy.html#getItems() getItems()]] and [[http://www.reportingstandard.com/apidoc/com/ihr/xbrl/om/taxonomy/XBRLTaxonomy.html#getTuples() getTuples()]] or access to individual concepts if the concept name is known [[http://www.reportingstandard.com/apidoc/com/ihr/xbrl/om/taxonomy/XBRLTaxonomy.html#getElementDefinitionByName(java.lang.String) getElementDefinitionByName(String name)]] or the id [[http://www.reportingstandard.com/apidoc/com/ihr/xbrl/om/taxonomy/XBRLTaxonomy.html#getElementDefinitionById(java.lang.String) getElementDefinitionById(String id)]].


The content of some parts of the context container can be parameterized in order make them dynamic. The dynamic content will be calculated at the time the report is generated. The calculated value will be used in the resulting document in the part that corresponds according to the template.
Note: the [[DTSContainer]] object contains a method [[http://www.reportingstandard.com/apidoc/com/ihr/xbrl/om/DTSContainer.html#getConcept(javax.xml.namespace.QName) getConcept(QName qname)]] to access to a concept defined in the DTS regardless in which taxonomy the concept is defined. The parameter to that function is the concept QName. Sometimes it is more convenient using that function than having to obtain the XBRLTaxonomy first and ask for the concept later.


Context templates may have dimensions in the segment and scenario containers.
====Write access====
The XBRLTaxonomy API has two methods [[http://www.reportingstandard.com/apidoc/com/ihr/xbrl/om/taxonomy/XBRLTaxonomy.html#addElement(com.ihr.xbrl.om.taxonomy.XMLElementDefinition) addElement(XMLElementDefinition)]] and [[http://www.reportingstandard.com/apidoc/com/ihr/xbrl/om/taxonomy/XBRLTaxonomy.html#delElement(com.ihr.xbrl.om.taxonomy.XMLElementDefinition) delElement(XMLElementDefinition)]] that allows the user to add or delete concept definitions from an XBRLTaxonomy. The [[XBRLItem]], [[XBRLTuple]] and [[XMLElementDefinition]] already takes care of calling this methods if the parent argument is properly set. So there should be no need to worry about consistency about what concepts belongs to what taxonomy.


This is a very simple example of contexts inside the template file:
Note: if you change a concept from one taxonomy to another, the concept local name will not be changed, but the concept namespace will no longer be the old namespace.
<syntaxhighlight lang="xml">
  <contexts>
    <scheme>http://www.xbrl.org/companyName</scheme>
    <company>The Sample Company Name</company>
    <!--
      Template for instant contexts
    -->
    <context id="ctx0i">
      <entity>
        <xbrli:identifier scheme="_">_</xbrli:identifier>
      </entity>
      <period>
        <instant>eoy-P1Y</instant>
      </period>
    </xbrli:context>
    <!--
      Template for duration contexts
    -->
    <context id="ctx0d">
      <entity>
        <xbrli:identifier scheme="_">_</xbrli:identifier>
      </entity>
      <period>
        <startDate>boy-P1Y</startDate>
        <endDate>eoy-P1Y</endDate>
      </period>
    </context>
  </contexts>
</syntaxhighlight>


The first two elements of the contexts element are '''scheme''' and '''company'''. The value of those elements is any string value for company and a valid URI value for the scheme element. The values indicated here will be used in order to substitute the content of the XBRL identifiers in the real contexts. When the value of the scheme attribute in the identifier elements is an underscore character '''"_"''', the mapper processor will substitute the underscore character by the value indicated in the scheme element. When the processor find an underscore character are the value of the identifier element, it will be substituted by the value of the company element.
===Working with Role Types===
The use of role types in XBRL comes originally from the XLink specification. The idea of the authors of the XLink specification was to allow document authors to put additional information on XLink related elements about the role of the elements (locators, arcs and resources) so the consuming applications can do something with them. In XBRL we did three things:
# we standardize the definition of some role types in the XBRL 2.1 specification
# we allow a standard mechanism in the XBRL 2.1 specification so new role types can be defined in taxonomies
# we provide semantic meaning to the use of role types on different elements like resources and extended links.


The dates on '''instant''', '''startDate''' and '''endDate''' elements in the context can also be parameterized. The valid values are:
In this section about taxonomies we are not going to explore all possibilities about role types, our goal is to let you know that the XBRL API allows you to:
* a date; in this case it is not parameterized, it is just a fixed date, or
* find role types in the DTS (defined in the XBRL spec or in the loaded taxonomies)
* the token "boy" (Beginning Of the Year) optionally followed by a + or - sign and the declaration of a period using XML Schema notation. "boy" will be dynamically substituted by the date of the beginning of the current year, or
* add new role types to the DTS
* the token "eoy" (End Of the Year) optionally followed by a + or - sign and the declaration of a period using XML Schema notation. "eoy" will be dynamically substituted by the last date of the current year, or
* delete existing role types (only if they are not defined in the XBRL spec)
* the token "now" that indicates current date.


Each context here must have a context id that will be referenced from '''item''' elements declaring item generation events.
====Read access====
The method [[http://www.reportingstandard.com/apidoc/com/ihr/xbrl/om/taxonomy/XBRLTaxonomy.html#getRoleTypes() getRoleTypes()]] returns an iterator over all role types [[XBRLRoleType]] defined in this taxonomy. The method [[http://www.reportingstandard.com/apidoc/com/ihr/xbrl/om/taxonomy/XBRLTaxonomy.html#getRoleTypeByURI(java.lang.String) getRoleTypeByURI(String URI)]] returns a role type [[XBRLRoleType]] object if there is a role type defined in this taxonomy for the corresponding URI value.


====Units====
Note, there is a [[http://www.reportingstandard.com/apidoc/com/ihr/xbrl/om/DTSContainer.html#getRoleType(java.lang.String) getRoleType(String URI)]] method in the [[DTSContainer]] object that returns a role type [[XBRLRoleType]] regardless in which taxonomy the role type is defined or if the role type is a static role type defined in the XBRL 2.1 specification.


The next part of the instance template document after the contexts element is the '''units''' (in plural) element. This element wraps all units used by item data events.
====Write access====
The method [[http://www.reportingstandard.com/apidoc/com/ihr/xbrl/om/taxonomy/XBRLTaxonomy.html#addRoleType(com.ihr.xbrl.om.taxonomy.XBRLRoleType) addRoleType(XBRLRoleType newRole)]] adds a new role type to the taxonomy. The method [[http://www.reportingstandard.com/apidoc/com/ihr/xbrl/om/taxonomy/XBRLTaxonomy.html#removeRoleType(com.ihr.xbrl.om.taxonomy.XBRLRoleType) removeRoleType(XBRLRoleType roleType)]] removes an existing role from the taxonomy. Both methods are automatically called by the [[XBRLRoleType]] class when it is necessary so there should be no need to call this methods manually from XBRL applications.


The content of the units elements are xbrl units as they appear in XBRL reports.
===Working with Arcrole Types===
The use of arcrole types in XBRL comes originally from the XLink specification. The idea of the authors of the XLink specification was to allow document authors to put additional information on XLink arcs so the consuming applications can do something with them. In XBRL we did two things:
# we standardize the definition of some arcrole types in the XBRL 2.1 specification
# we allow a standard mechanism in the XBRL 2.1 specification so new arcrole types can be defined in taxonomies


This is an example of a units element with content:
In this section about taxonomies we are not going to explore all possibilities about arcrole types, our goal is to let you know that the XBRL API allows you to:
<syntaxhighlight lang="xml">
* find arcrole types in the DTS (defined in the XBRL spec or in the loaded taxonomies)
  <units>
* add new arcrole types to the DTS
    <xbrli:unit id="Euros">
* delete existing arcrole types (only if they are not defined in the XBRL spec)
      <xbrli:measure xmlns:iso4217="http://www.xbrl.org/2003/iso4217">iso4217:EUR</xbrli:measure>
    </xbrli:unit>
  </units>
</syntaxhighlight>


Units must have an id that will be referenced from item data events.
====Read access====
The method [[http://www.reportingstandard.com/apidoc/com/ihr/xbrl/om/taxonomy/XBRLTaxonomy.html#getArcroleTypes() getArcroleTypes()]] returns an iterator over all arcrole types [[XBRLArcroleType]] defined in this taxonomy. The method [[http://www.reportingstandard.com/apidoc/com/ihr/xbrl/om/taxonomy/XBRLTaxonomy.html#getArcroleTypeByURI(java.lang.String) getArcroleTypeByURI(String URI)]] returns an arcrole type [[XBRLArcroleType]] object if there is an arcrole type defined in this taxonomy for the corresponding URI value.


====Events====
Note, there is a [[http://www.reportingstandard.com/apidoc/com/ihr/xbrl/om/DTSContainer.html#getArcroleType(java.lang.String) getArcroleType(String URI)]] method in the [[DTSContainer]] object that returns an arcrole type [[XBRLArcroleType]] regardless in which taxonomy the arcrole type is defined or if the arcrole type is a static arcrole type defined in the XBRL 2.1 specification.


Linking all together; the most important part of the instance template document are the events. Events are defined in order to obtain data from drivers and according to the [[Mapper to driver data exchange dialog|mapper to driver data exchange dialog]]. The '''facts''' element wraps the content of all events defined in an XBRL Template File.
====Write access====
The method [[http://www.reportingstandard.com/apidoc/com/ihr/xbrl/om/taxonomy/XBRLTaxonomy.html#addArcroleType(com.ihr.xbrl.om.taxonomy.XBRLArcroleType) addArcroleType(XBRLArcroleType newArcrole)]] adds a new arcrole type to the taxonomy. The method [[http://www.reportingstandard.com/apidoc/com/ihr/xbrl/om/taxonomy/XBRLTaxonomy.html#removeArcroleType(com.ihr.xbrl.om.taxonomy.XBRLArcroleType) removeArcroleType(XBRLArcroleType arcroleType)]] removes an existing arcrole from the taxonomy. Both methods are automatically called by the [[XBRLArcroleType]] class when it is necessary so there should be no need to call this methods manually from XBRL applications.


The following piece of XML code is the declaration of an event in order to obtain data for an item fact. All required information for the event definition is stored in attributes. Part of the information is required and other parts are optional.
===Working with Imported Taxonomies===
<syntaxhighlight lang="xml">
An XBRL Taxonomy (which is an XML Schema) can reference other XBRL Taxonomies (that, in turn are other XML Schemas) using the XML Schema <xsd:import namespace="..." schemaLocation="..."/> statement. This facilitates that all required pieces to make a taxonomy meaningful are always read together. For example; global type definitions can be all defined in separate smaller XML Schemas so they can be reused from one taxonomy version to the next one if there are no changes in the business model that is behind the type definition.
    <item sourceRef="source0" contextRef="ctx0i" mapIdentifier="identifier0" concept="tx:A" unitRef="Euros"/>
</syntaxhighlight>


The attributes defined in a fact item data capturing event are:
The XBRL API allows the user to get access to the imported schemas of a taxonomy schema and to add and remove imported schemas manually. The surrounding class that represents imports is [[XBRLImport]]. That class automatically takes care of consistency.
* required ''sourceRef'', this attribute content must match with the id of the '''source''' to be informed about the event.
* required ''contextRef'', this attribute content must match with the id of one of the contexts defined in the '''contexts''' section.
* required ''mapIdentifier'', this attribute holds the event name and will be used by drivers. See the [[Mapper to driver data exchange dialog|mapper to driver data exchange dialog]] wiki page for more information.
* required ''concept'', this attribute hold the concept QName this item refers to. The concept must be defined in a taxonomy schema that is part of the DTS declared in the DTS section.
* optional ''unitRef'', this attribute content must match with the id of one of the units defined in the '''units''' section. The attribute is optional because non numeric concepts does not require units. If the used does not add this optional attribute in a numeric fact then the driver would be responsible of adding a unit. If the driver does not add a unit then the produced instance document may not be valid
* optional ''multi'', this attribute defines the behavior of the engine generating the report when the driver returns more than one value for this event and the element is inside a tuple. Possible values are "All", "Single", "Prev" or an integer. See the [[Mapper to driver data exchange dialog|mapper to driver data exchange dialog]] wiki page for more information.


The following piece of XML code is the declaration of a sample event in order to obtain data for a tuple fact.
====Read access====
<syntaxhighlight lang="xml">
The method [[http://www.reportingstandard.com/apidoc/com/ihr/xbrl/om/taxonomy/XBRLTaxonomy.html#getImports() getImports()]] returns an iterator over all [[XBRLImport]] objects of this taxonomy schema. The method [[http://www.reportingstandard.com/apidoc/com/ihr/xbrl/om/taxonomy/XBRLTaxonomy.html#getImport(java.net.URI) getImport(String namespaceURI)]] returns the imported schema that corresponds to the namespace indicated in the parameter or null if the taxonomy schema for that namespace is not found.
  <tuple concept="tx:T">
    ... here goes the tuple specific events; they are other item events or tuple events. Events can be nested in order to represent tuple structures in the instance document ...
  </tuple>
</syntaxhighlight>


The declaration of events in order to populate content for tuples contains the following attributes:
====Write access====
* required ''concept'', this attribute holds the concept QName this tuple refers to. The concept must be defined in a taxonomy schema that is part of the DTS declared in the DTS section.
The method [[http://www.reportingstandard.com/apidoc/com/ihr/xbrl/om/taxonomy/XBRLTaxonomy.html#addImport(com.ihr.xbrl.om.taxonomy.XBRLImport) addImport(XBRLImport import)]] adds a new import to the current taxonomy schema. The method [[http://www.reportingstandard.com/apidoc/com/ihr/xbrl/om/taxonomy/XBRLTaxonomy.html#removeImport(com.ihr.xbrl.om.taxonomy.XBRLImport) removeImport(XBRLImport import)]] removes an import from the list of imported schemas on the current taxonomy. The [[XBRLImport]] class  already takes care of calling addImport and removeImport in the parent object during calls to the [[http://www.reportingstandard.com/apidoc/com/ihr/xbrl/om/taxonomy/XBRLImport.html#setParent(com.ihr.xbrl.om.taxonomy.XBRLTaxonomy) setParent(XBRLTaxonomy parent)]] method so there should be no need to call this methods directly from client code.
* optional ''mapIdentifier'', this attribute holds the event name and will be used by drivers. Due to the reason that tuple content are items or other tuples, the mapIdentifier here is optional. If there is no mapIdentifier attribute declared none of the drivers will be informed about the event for generating a tuple, one instantiation of the tuple will be created automatically in order to populate the tuple content.
* optional ''multi'', this attribute defines the behavior of the engine generating the report when there is a nested tuple inside a parent tuple and there are more than one fact tuples to be created in the report. See the [[Mapper to driver data exchange dialog|mapper to driver data exchange dialog]] wiki page for more information.
* optional ''sourceRef'', if the attribute exist its content must match with the id of the '''source''' to be informed about the event. If the attribute exists, the driver will be responsible of calculating the number of fact tuples that the final instance document will contain. See the [[Mapper to driver data exchange dialog|mapper to driver data exchange dialog]] wiki page for more information.


An event is declared and named using the ''mapIdentifier'' attribute in either a '''tuple''' or an '''item''' element. The content of that attribute is a string that identifies the event name. Other GUI tools and drivers will use the content of the mapIdentifier attribute in order to match it with the function that obtains values from the data source.
===Working with external and embedded linkbases===


Sample content of a facts element:
XBRL Linkbases are containers of extended links. For more information about this topic visit the wiki page about the [[XBRLLinkbase]] document object. An XBRL Taxonomy may contain either references to external linkbases or embeded linkbases. Applications working with the content of an XBRL Taxonomy can explore and change all linkbases that are referenced or embedded in an XBRL Taxonomy using simple API calls.
<syntaxhighlight lang="xml">
  <facts xmlns:tx="http://taxonomy.com/example">


    <!-- this is a single item event -->
====Read access====
    <item sourceRef="source0" contextRef="ctx0i" mapIdentifier="identifier0" concept="tx:A" unitRef="Euros"/>
A call to the method [[http://www.reportingstandard.com/apidoc/com/ihr/xbrl/om/taxonomy/XBRLTaxonomy.html#getLinkbases() getLinkbases()]] returns an iterator over all linkbases that are embedded or referenced from this taxonomy schema. The iterator returns objects of the type [[XBRLLinkbase]]. An embedded linkbase can be easily diferenciated from a referenced linkbase because the parent of an embedded linkbase is always an XBRL Taxonomy schema and the parent object of a referenced linkbase (external to the taxonomy) is the same referenced linkbase.


    <!-- this is a single tuple event with no name -->
====Write access====
    <tuple concept="tx:T">
The user can call the method [[http://www.reportingstandard.com/apidoc/com/ihr/xbrl/om/taxonomy/XBRLTaxonomy.html#addLinkbase(com.ihr.xbrl.om.exLinks.XBRLLinkbase) addLinkbase(XBRLLinkbase newLinkase)]] in order to add an embedded or external linkbase to an XBRL Taxonomy. The user can call the method [[http://www.reportingstandard.com/apidoc/com/ihr/xbrl/om/taxonomy/XBRLTaxonomy.html#removeLinkbase(com.ihr.xbrl.om.exLinks.XBRLLinkbase) removeLinkbase(XBRLLinkbase linkbase)]] in order to remove an existing external or embedded linkbase from this XBRL Taxonomy. Note the user must explicitly call addLinkbase and removeLinkbase methods in order to create the DTS structure they want.
      <tuple concept="tx:T">
        <item sourceRef="source0" contextRef="ctx0i" mapIdentifier="identifier1" concept="tx:B" multi="Single" unitRef="Euros"/>
        <item sourceRef="source0" contextRef="ctx0dim" mapIdentifier="identifier3" concept="tx:C" multi="2" unitRef="Euros"/>
      </tuple>
      <item sourceRef="source0" contextRef="ctx0i" mapIdentifier="identifier1" concept="tx:B" multi="All" unitRef="Euros"/>
    </tuple>


    <!-- this is a second tuple -->
===Working with global XML Schema objects===
    <tuple concept="tx:U">
      <item sourceRef="source0" contextRef="ctx0i" mapIdentifier="identifier2" concept="tx:B" multi="1" unitRef="Euros"/>
    </tuple>


    <!-- dimensional item -->
===Navigation===
    <item sourceRef="source0" contextRef="ctx0dim" mapIdentifier="identifier3" concept="tx:C" unitRef="Euros"/>
[[Main Page]] | [[XBRL API related discussions]]
  </facts>
</syntaxhighlight>
==Navigation==
[[Main Page]] | [[XBRLmapper]]

Revision as of 14:49, 11 August 2009

[XBRLTaxonomy javadoc page]

Description

An XBRLTaxonomy object represents the content of an XBRL Taxonomy and the surrounding XML Schema. This is:

  • the Namespace, and
  • all XBRL concept definitions (items and tuples) , and
  • all XBRL role types locally defined, and
  • all XBRL arcrole types locally defined, and
  • all references to imported XBRL Taxonomies, and
  • all references to external and embedded XBRL Linkbases, and
  • all other XML Schema related constructions like global groups, global type declarations, global attribute groups, global attribute declarations and global element declarations that are not XBRL concepts.

How to create an instance of an XBRLTaxonomy object

There are several ways depending on what the user needs are:

  • If the user have just created a new empty DTSContainer object and the purpose is to read the content of an XBRL taxonomy (and the whole referenced DTS) then the simplest way is to use one of the load methods in the DTSContainer object passing the document URI of the XBRL taxonomy. The returned object is an XBRLTaxonomy that can be casted to an XBRLTaxonomy.
  • If the user has already loaded a DTS (from another taxonomy file or an XBRL report) and the purpose is to create a new XBRLTaxonomy (in order to create a taxonomy extension) then, the user can use any of the available [constructors]. The most commonly used constructor is [XBRLTaxonomy(com.ihr.xbrl.om.DTSContainer)] that accepts the current DTSContainer as a parameter and allows the user to start adding concepts programatically.

Creation of a XBRLTaxonomy object from a local file name: <syntaxhighlight lang="java"> /**

* Sample, a new XBRLTaxonomy document is read form the file received as a parameter
* After the instance object is obtained, the user can start working with it
*/

public class SampleReadTaxonomy {

 public static void main(String[] args) throws Exception {
   DTSContainer dts = DTSContainer.newEmptyContainer();
   XBRLTaxonomy taxonomy = (XBRLTaxonomy)dts.load(new File(args[0]).toURI());
   // ... rest of the application code goes here
 }

} </syntaxhighlight>

Creation of a new taxonomy document for a DTS after the DTS has been loaded: <syntaxhighlight lang="java"> /**

* Sample, a new instance document is created after the DTS has been loaded
*/

public class SampleCreateTaxonomyExtension {

 public static void main(String[] args) throws Exception {
   DTSContainer dts = DTSContainer.newEmptyContainer();
   dts.load(new File("sampleTaxonomy.xsd").toURI());
   XBRLTaxonomy taxonomy = new XBRLTaxonomy(dts);
   // adds taxonomy default minimum information
   String targetNamespace = "http://www.reportingstandard.com/samples/2009/newTaxonomy";
   tx.setURI(new URI("taxonomyExtension.xsd"));
   tx.setTargetNamespace(targetNamespace);
   tx.addNamespace("tx", targetNamespace);
   dts.addDocumentToDTS(tx);
   // ... rest of the application code goes here
   // Save the Taxonomy extension to disk
   dts.save(true);
 }

} </syntaxhighlight>

The Namespace

XBRL Taxonomies are the containers of concept definitions. Concept definitions must be unique worldwide (assets in the US-GAAP and assets in the IFRS). The mechanism provided by the W3C consortium in order to allow easy distinction between concepts defined in different taxonomies is called namespaces.

Each taxonomy is an XML Schema. An XML Schema may define a Namespace. The namespace is a unique name that may be of a form of a URI (Unique Resource Identifier).

For example:

  • IFRS 2009 concepts namespace is: http://xbrl.iasb.org/taxonomy/2009-04-01/ifrs
  • US-GAAP 2009 concepts namespace is: http://xbrl.us/us-gaap/2009-01-31

Here is the [link for the Namespaces specification] at the W3C consortium.

Read access

The API call [getTargetNamespace()] gives direct access to the taxonomy namespace.

Write access

The API call [setTargetNamespace(String namespace)] sets or changes the taxonomy namespace.

Working with concept definitions

We can classify XBRL Taxonomies in two categories:

  1. Taxonomies that defines new concepts: They are XBRL Taxonomies that contains new concept definitions. A concept definition is an element in the item or tuple substitution group. Normally, Taxonomies that defines new concepts also include references to the labels and reference linkbases.
  2. Taxonomies that does not define new concepts: They are XBRL Taxonomies that serves organize the content of the DTS, for example, including a common set of presentation and calculation linkbases together.

Read access

While working with an XBRL Taxonomy, the user may be interested in accessing concepts defined. The XBRLTaxonomy API provides methods for exploring all concept definitions [getConcepts()], [getItems()] and [getTuples()] or access to individual concepts if the concept name is known [getElementDefinitionByName(String name)] or the id [getElementDefinitionById(String id)].

Note: the DTSContainer object contains a method [getConcept(QName qname)] to access to a concept defined in the DTS regardless in which taxonomy the concept is defined. The parameter to that function is the concept QName. Sometimes it is more convenient using that function than having to obtain the XBRLTaxonomy first and ask for the concept later.

Write access

The XBRLTaxonomy API has two methods [addElement(XMLElementDefinition)] and [delElement(XMLElementDefinition)] that allows the user to add or delete concept definitions from an XBRLTaxonomy. The XBRLItem, XBRLTuple and XMLElementDefinition already takes care of calling this methods if the parent argument is properly set. So there should be no need to worry about consistency about what concepts belongs to what taxonomy.

Note: if you change a concept from one taxonomy to another, the concept local name will not be changed, but the concept namespace will no longer be the old namespace.

Working with Role Types

The use of role types in XBRL comes originally from the XLink specification. The idea of the authors of the XLink specification was to allow document authors to put additional information on XLink related elements about the role of the elements (locators, arcs and resources) so the consuming applications can do something with them. In XBRL we did three things:

  1. we standardize the definition of some role types in the XBRL 2.1 specification
  2. we allow a standard mechanism in the XBRL 2.1 specification so new role types can be defined in taxonomies
  3. we provide semantic meaning to the use of role types on different elements like resources and extended links.

In this section about taxonomies we are not going to explore all possibilities about role types, our goal is to let you know that the XBRL API allows you to:

  • find role types in the DTS (defined in the XBRL spec or in the loaded taxonomies)
  • add new role types to the DTS
  • delete existing role types (only if they are not defined in the XBRL spec)

Read access

The method [getRoleTypes()] returns an iterator over all role types XBRLRoleType defined in this taxonomy. The method [getRoleTypeByURI(String URI)] returns a role type XBRLRoleType object if there is a role type defined in this taxonomy for the corresponding URI value.

Note, there is a [getRoleType(String URI)] method in the DTSContainer object that returns a role type XBRLRoleType regardless in which taxonomy the role type is defined or if the role type is a static role type defined in the XBRL 2.1 specification.

Write access

The method [addRoleType(XBRLRoleType newRole)] adds a new role type to the taxonomy. The method [removeRoleType(XBRLRoleType roleType)] removes an existing role from the taxonomy. Both methods are automatically called by the XBRLRoleType class when it is necessary so there should be no need to call this methods manually from XBRL applications.

Working with Arcrole Types

The use of arcrole types in XBRL comes originally from the XLink specification. The idea of the authors of the XLink specification was to allow document authors to put additional information on XLink arcs so the consuming applications can do something with them. In XBRL we did two things:

  1. we standardize the definition of some arcrole types in the XBRL 2.1 specification
  2. we allow a standard mechanism in the XBRL 2.1 specification so new arcrole types can be defined in taxonomies

In this section about taxonomies we are not going to explore all possibilities about arcrole types, our goal is to let you know that the XBRL API allows you to:

  • find arcrole types in the DTS (defined in the XBRL spec or in the loaded taxonomies)
  • add new arcrole types to the DTS
  • delete existing arcrole types (only if they are not defined in the XBRL spec)

Read access

The method [getArcroleTypes()] returns an iterator over all arcrole types XBRLArcroleType defined in this taxonomy. The method [getArcroleTypeByURI(String URI)] returns an arcrole type XBRLArcroleType object if there is an arcrole type defined in this taxonomy for the corresponding URI value.

Note, there is a [getArcroleType(String URI)] method in the DTSContainer object that returns an arcrole type XBRLArcroleType regardless in which taxonomy the arcrole type is defined or if the arcrole type is a static arcrole type defined in the XBRL 2.1 specification.

Write access

The method [addArcroleType(XBRLArcroleType newArcrole)] adds a new arcrole type to the taxonomy. The method [removeArcroleType(XBRLArcroleType arcroleType)] removes an existing arcrole from the taxonomy. Both methods are automatically called by the XBRLArcroleType class when it is necessary so there should be no need to call this methods manually from XBRL applications.

Working with Imported Taxonomies

An XBRL Taxonomy (which is an XML Schema) can reference other XBRL Taxonomies (that, in turn are other XML Schemas) using the XML Schema <xsd:import namespace="..." schemaLocation="..."/> statement. This facilitates that all required pieces to make a taxonomy meaningful are always read together. For example; global type definitions can be all defined in separate smaller XML Schemas so they can be reused from one taxonomy version to the next one if there are no changes in the business model that is behind the type definition.

The XBRL API allows the user to get access to the imported schemas of a taxonomy schema and to add and remove imported schemas manually. The surrounding class that represents imports is XBRLImport. That class automatically takes care of consistency.

Read access

The method [getImports()] returns an iterator over all XBRLImport objects of this taxonomy schema. The method [getImport(String namespaceURI)] returns the imported schema that corresponds to the namespace indicated in the parameter or null if the taxonomy schema for that namespace is not found.

Write access

The method [addImport(XBRLImport import)] adds a new import to the current taxonomy schema. The method [removeImport(XBRLImport import)] removes an import from the list of imported schemas on the current taxonomy. The XBRLImport class already takes care of calling addImport and removeImport in the parent object during calls to the [setParent(XBRLTaxonomy parent)] method so there should be no need to call this methods directly from client code.

Working with external and embedded linkbases

XBRL Linkbases are containers of extended links. For more information about this topic visit the wiki page about the XBRLLinkbase document object. An XBRL Taxonomy may contain either references to external linkbases or embeded linkbases. Applications working with the content of an XBRL Taxonomy can explore and change all linkbases that are referenced or embedded in an XBRL Taxonomy using simple API calls.

Read access

A call to the method [getLinkbases()] returns an iterator over all linkbases that are embedded or referenced from this taxonomy schema. The iterator returns objects of the type XBRLLinkbase. An embedded linkbase can be easily diferenciated from a referenced linkbase because the parent of an embedded linkbase is always an XBRL Taxonomy schema and the parent object of a referenced linkbase (external to the taxonomy) is the same referenced linkbase.

Write access

The user can call the method [addLinkbase(XBRLLinkbase newLinkase)] in order to add an embedded or external linkbase to an XBRL Taxonomy. The user can call the method [removeLinkbase(XBRLLinkbase linkbase)] in order to remove an existing external or embedded linkbase from this XBRL Taxonomy. Note the user must explicitly call addLinkbase and removeLinkbase methods in order to create the DTS structure they want.

Working with global XML Schema objects

Navigation

Main Page | XBRL API related discussions