XBRLInstance and XBRLTaxonomy: Difference between pages

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


* all XBRL facts , and
* the Namespace, and
* all XBRL contexts, and
* all XBRL concept definitions (items and tuples) , and
* all XBRL units, and
* all XBRL role types locally defined, and
* all Footnote Linkbases, and
* all XBRL arcrole types locally defined, and
* all references to XBRLTaxonomies, XBRLLinkbases, XBRLRoleRef and XBRLArcroleRef required for obtaining the DTS.
* all references to imported XBRL Taxonomies, and
* all references to external XBRL Linkbases, and
* all 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 XBRLInstance object===
===How to create an instance of an XBRLTaxonomy object===


There are several ways depending on what you are doing:
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 report (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 report. The returned object is an XBRLDocument that can be casted to an XBRLInstance.
* 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 a taxonomy file) and the purpose is to create a new XBRLInstance (in order to populate it with facts) then the user can use any of the available [http://www.reportingstandard.com/apidoc/com/ihr/xbrl/om/instance/XBRLInstance.html#constructor_summary constructors]. The most commonly used constructor is [http://www.reportingstandard.com/apidoc/com/ihr/xbrl/om/instance/XBRLInstance.html#XBRLInstance(com.ihr.xbrl.om.DTSContainer) XBRLInstance(com.ihr.xbrl.om.DTSContainer)] that accepts the current DTSContainer as a parameter and allows the user to start adding facts programatically.
* 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.


Creation of a XBRLInstance object from a local file name:
Creation of a XBRLTaxonomy object from a local file name:
<pre>
<syntaxhighlight lang="java">
/**
/**
  * Sample, a new instance document is read form the file received as a parameter
  * 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
  * After the instance object is obtained, the user can start working with it
  */
  */
public class SampleReadInstance {
public class SampleReadTaxonomy {


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


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


public static void main(String[] args) throws Exception {
  public static void main(String[] args) throws Exception {
DTSContainer dts = DTSContainer.newEmptyContainer();
    DTSContainer dts = DTSContainer.newEmptyContainer();
dts.load(new File("sampleTaxonomy.xsd").toURI());
    dts.load(new File("sampleTaxonomy.xsd").toURI());
XBRLInstance instance = new XBRLInstance(dts);
// ... rest of the application code goes here
}
}
</pre>


===Working with facts in an XBRLInstance===
    XBRLTaxonomy taxonomy = new XBRLTaxonomy(dts);


This section describes two abstract operations that the user can execute on XBRLInstance objects regardless the way they have been created.
    // 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);


The XBRLInstance object is able to automatically change in order to keep consistency during operations. For example, the action of adding a new XBRLFact item to the XBRLInstance may automatically add a new context or may reuse an existing context instead. The same happens with the unit and with the reference to the required taxonomy schema. Removing facts from the XBRLInstance is also an operation that keeps the instance document content consistent while silently removes content that is no longer used (like unused units or contexts etc).
    // ... rest of the application code goes here


====Read access====
    // Save the Taxonomy extension to disk
    dts.save(true);
  }
}
</syntaxhighlight>


Read access of facts in an XBRLInstance is an abstract operation implemented in several methods. The content of an XBRLInstance can be accessed in two modes: '''sequential mode''' and '''indexed mode'''. Both modes serves different purposes while working with data in an XBRLInstance. Both are described in the [[XBRLFactsList]] interface.
===The Namespace===


In this example, the content of the XBRLInstance document is sequentially accessed in document order:
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.
<pre>
Iterator<XBRLFact> iterF = instance.iterator();
while (iterF.hasNext()) {
XBRLFact fact = iterF.next();
// ... do some work with the fact
}
</pre>


====Write access====
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).


Creating a fact is a very simple task. The user just need to call the apropriate constructor depending on the type of fact to be created. The final fact types that the user can directly create are:
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>


* [[XBRLFactNonNumeric]]
Here is the [[http://www.w3.org/TR/xml-names/ link for the Namespaces specification]] at the W3C consortium.
* [[XBRLFactNumeric]]
* [[XBRLFactTuple]]


The API takes care automatically of the consistency inside the XBRLInstance when the user do operations with facts; for example, the action of creating a new fact automatically performs the operation of adding the new fact to the fact container (instance or tuple), take care of the fact context and unit (if it is necessary), add the taxonomy reference to the DTS if it is not in the current DTS, etc. The programmer does not need to worry about how to keep consistency in the content of the XBRLInstance object. Note that consistency does not imply XBRL Validation.
====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.


All objects representing facts above are non abstract objects in the fact object hierarchy. Objects up in the hierarchy contains shared functionalty in order to make the non abstract object meaningful. See the javadoc documentation of each one of the objects in order to learn more about the hierarchy.
====Write access====
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.


The following example contains several lines of code in order to create the auxiliary objects first. Then a new XBRLFactNonNumeric fact is created. In the last line of the code, a value is assigned to the new created fact.
===Working with concept definitions===
<pre>
We can classify XBRL Taxonomies in two categories:
  // create a context for the instant "Begning of year 2008"
# '''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.
  XBRLEntity ent = new XBRLEntity(dts,"http://www.xbrl.org/scheme","Sample Company",null);
# '''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.
  XBRLPeriod p = new XBRLPeriod(dts,"2008-01-01");
  XBRLContext ctx = new XBRLContext(dts,ent,p,null);
  // Obtain the concept definition of concept "A" from the DTS
  XBRLItem itemA = (XBRLItem)dts.getConcept(new QName(ns,"A"));
  // create the Non Numeric (Text) fact item
  XBRLFactNonNumeric fA = new XBRLFactNonNumeric(instance,ctx,itemA);


  // fA is nil until a value is assigned
====Read access====
  fA.setValue(new StringValue("sample text value"));
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)]].
</pre>


In this example, a new XBRLNumericFact is added to the XBRLInstance. The creation of the auxiliary objects has been omitted.
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.
<pre>
  // create the Non Numeric (Text) fact item
  XBRLFactNonNumeric fA = new XBRLFactNonNumeric(instance,ctx,itemA);


  // fA is nil until a value is assigned
====Write access====
  fA.setValue(new StringValue("test"));
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.
</pre>


===Managing the elements that compose the DTS===
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.


In normal circumnstances the user should never care about dealing with elements that compose the DTS of the XBRLInstance document. The required elements will be added automatically when you create the XBRLInstance object using a dts as a parameter and at the time you add facts to the instance document. This is particularly true for all required XBRL taxonomies used by concepts in the XBRLInstance, all required XBRL taxonomies where role types used in footnote extended link containers are defined and all required XBRL taxonomies where arcrole types used in relationships in the footnote extended link containers are defined. But, there is one (very rare) use case left that is when the user wants to add a custom existing linkbase to the DTS of the report that is not part of the DTS discovered by the taxonomy schemas already referenced. In this case, it is still possible adding those linkbases using any of the following two methods:
===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.


[http://www.reportingstandard.com/apidoc/com/ihr/xbrl/om/instance/XBRLInstance.html#addXBRLDocument(com.ihr.xbrl.om.XBRLDocument,%20com.ihr.xbrl.om.taxonomy.XBRLRoleAndArcroleTypes) addXBRLDocument(com.ihr.xbrl.om.XBRLDocument, com.ihr.xbrl.om.taxonomy.XBRLRoleAndArcroleTypes)]
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)


or
====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.


[http://www.reportingstandard.com/apidoc/com/ihr/xbrl/om/instance/XBRLInstance.html#addXBRLDocumentIfNotInDTS(com.ihr.xbrl.om.XBRLDocument,%20com.ihr.xbrl.om.taxonomy.XBRLRoleAndArcroleTypes) addXBRLDocumentIfNotInDTS(com.ihr.xbrl.om.XBRLDocument, com.ihr.xbrl.om.taxonomy.XBRLRoleAndArcroleTypes)]
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.


===Working with contexts===
====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.


===Working with units===
===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


===Working with footnotes===
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)


The user can create footnote containers in an XBRLInstance object. Footnote containers will hold all required elements in order to link the footnote text (in plain text or xhtml format) to a particular fact in the instance (the fact can be numeric, non numeric or a tuple).
====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.


Creating a footnote requires some initial work on the XBRLInstance:
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.


====Create the footnotes container====
====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.


A footnotes container is an XLink extended link container for XBRL footnotes. In order to create the container the user must first get the desired role type from the DTS and then call the FootnoteLinkbase constructor with the required parameters.
===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.


Here is an example about how to get the standard role URI from the [[DTSContainer]] object and then create an extended link for footnotes
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.
<pre>
XBRLRoleType role = dts.getStaticRoleTypeByURI(XBRLExtendedLink.standard_role_URI);


// Now create a container for footnotes (Footnote Extended Link)
====Read access====
FootnoteLinkbase fl = new FootnoteLinkbase(instance, role);
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.
</pre>


====Create the footnote resource====
====Write access====
 
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 class XBRLImport 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.
Reporting Standard API does not contain a specific resource type for footnotes. Footnote resources can be created using the base [[XBRLResource]] object from the API.
 
The following example demonstrates how to do it. Note that the creation of the resource requires other parameters that we have just explained how to create in this document. According to the parameters indicated in the example, the resource will be added to the parent footnote extended link container at the moment it is created. See the [[XBRLResource]] page for more information about the parameters.
 
<pre>
  // Create a Footnote resource and add it to the fl container
  XBRLResource footnoteRes = new XBRLResource(fl,FootnoteLinkbase.lbResource,true);
 
  // As footnotes can have simpleType content and complexType content (xhtml) the default is
  // complexType content. So we now force the resource to have simple type content.
  footnoteRes.setSimpleType();
 
  // Footnote resource requires some values to be set
  footnoteRes.setValue(new StringValue("Footnote content"));
  footnoteRes.setLang("en");
</pre>
 
====Create the relationship linking the fact with the footnote====
 
Finally, a relationship will join the fact in the report with the footnote resource. Creating a relationship requires providing some parameters we have already defined in this page. See the XBRL 2.1 specification for more information about the standard arcroles defined there.
 
<pre>
  // Create a relationship linking the fact with the footnote.
  XBRLArcroleType fact_footnote = dts.getStaticArcroleTypeByURI(FootnoteLinkbase.fact_footnote_arcrole_URI);
  new XBRLRelationship(fl,FootnoteLinkbase.standard_arc,fA,footnoteRes,fact_footnote,null,true);
</pre>
 
====Cheking is a fact contains footnotes====
 
====Reading footnotes in an XBRLInstance====
 
===Navigation===
[[Main Page]] | [[XBRL API related discussions]]

Revision as of 12:53, 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 XBRL Linkbases, and
  • all 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 class XBRLImport 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.