XBRLmapper and XBRLTaxonomy: Difference between pages

From XBRLWiki
(Difference between pages)
Jump to navigationJump to search
 
 
Line 1: Line 1:
[[File:XBRLMapperMain.png|thumb|right|XBRL Mapper tool main window]]
[[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:


==Product page==
* 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.


[[http://www.reportingstandard.com/XBRL_Mapper.xhtml XBRL Mapper product page]]
===How to create an instance of an XBRLTaxonomy object===


[[File:XBRLMapperIcon.png|none|left|XBRL Mapper tool icon]]
There are several ways depending on what the user needs are:


==Description==
* 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.


XBRLmapper is a sophisticated tool that transfers data from information systems to XBRL reports and from XBRL reports to other systems. It supports then two different purposes:
* 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.


# Automatic generation of XBRL reports from different data sources
Creation of a XBRLTaxonomy object from a local file name:
# Automatic extraction of data from XBRL reports and data loading into different repositories
<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 {


Both products share a similar architecture. Both are based on a common definition of ''data events'' connected with the XBRL side and specific ''drivers'' that attend the data events. Both sides (''definition of events'', and ''drivers'') can be configured using XML files. This architecture has multiple advantages:
  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>


# Isolates the complexity of the XBRL technology in one part (the definition of the data events). If there are changes in the taxonomy, the user may need to change just the definition of the data events
Creation of a new taxonomy document for a DTS after the DTS has been loaded:
# Isolates the complexity of the internal data repositories. Each one of the data repositories can be accessed by an instantiation of a driver
<syntaxhighlight lang="java">
# Each driver has his own configuration file
/**
# Drivers are defined for the repository data format
* Sample, a new instance document is created after the DTS has been loaded
# The generation of an XBRL report may involve several drivers looking at data in different repositores simultaneously
*/
# The same event could be potentially attended by more than one driver if this is required
public class SampleCreateTaxonomyExtension {
# Multiple drivers of the same repository type can be used concurrently


The XBRL mapper is a software component that can be launched from a GUI or can be integrated in a workflow. The integration requires development of code (in Java or .NET)
  public static void main(String[] args) throws Exception {
    DTSContainer dts = DTSContainer.newEmptyContainer();
    dts.load(new File("sampleTaxonomy.xsd").toURI());


==Generating XBRL (Mapper)==
    XBRLTaxonomy taxonomy = new XBRLTaxonomy(dts);


Generating XBRL reports is one of the operations for which the mapper was conceived. In this documentation Mapping is the process of obtaining data from data repositories in order to create an XBRL report.
    // 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 XBRL Mapper product designed by Reporting Standard S.L. can be used in the most complex scenarios. The XBRL Mapper is robuts, powerful and flexible.
    // ... rest of the application code goes here


* Robust because it is based on a native XBRL API that supports 100% Conformance level with XBRL Validation
    // Save the Taxonomy extension to disk
* Powerful because it is based on an architecture that allows the users to plug-in drivers prepared to read different data sources and prepare combinations of data sources attending "mapping events".
    dts.save(true);
* Flexible because it allows users to easily migrate to new taxonomies by just changing the instance document template but maintaining the same "mapping event" names and driver configurations. Or to adapt the system to obtain data from different data sources while using the same target taxonomy.
  }
}
</syntaxhighlight>


The configuration of the mapping engine requires then two steps:
===The Namespace===


# Preparing an instance document template. This is the definition of "mapping 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.
# Preparing the configuration file for the driver(s) attending "mapping events"


===The instance document template===
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 instance document template is the configuration file where the "mapping events" are defined. As the name suggest, the instance document template resembles an XBRL report but it is parameterized in order to turn each one of the facts in a report into a "mapping event". It is important to notice that while the instance document template may have just one fact for a concept definition in the taxonomy, the response from drivers about requesting data for one mapping event may be multiple facts and, if this is the case, the final output file will have multiple facts as a result of multiple data items for the same mapping event.
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 creation of an initial instance document template is a straingt forward process that can be initiated from two different sources, the file can be adapted to cover more complex mapping scenarios later.
Here is the [[http://www.w3.org/TR/xml-names/ link for the Namespaces specification]] at the W3C consortium.


The [[XBRL Template File]] page on this wiki explains the format of the template files and how the user can create their own files for more complex mapping scenarios.
====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.


====From a DTS (A set of Taxonomies and Linkbases)====
====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.


In this case, the instance document template will be generated according to all concept definitions that exists in the DTS (all taxonomy schemas providing item and tuple definitions for the DTS). If the purpose of the instance document template is just the concepts in a specific presentation hierarchy it would be more interesting prepating a sample instance document and convert the sample report into an instance document template (See the next section).
===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.


So, the creation of an instance document template from a complete DTS may generate a template with lots of events. The user should use this option if he is absolutely sure this is the way to go.
====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)]].


Steps to produce the initial template file:
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.
# Open Loader Editor tool
# In the "Mapper" menu, select the "New Template from DTS" option
# In the [[Compose DTS]] dialog, select the required files
# Make sure there is a template file name in the [[Simple Instance Document Template Dialog|dialog to generate a simple instance document template]]. The file name extension should be (*.xbrlt).
# Make sure there is one initial data source in the [[Simple Instance Document Template Dialog|dialog to generate a simple instance document template]] (more data sources can be added later).
# A template will be generated and loaded into the XBRLMapper main window.


====From a sample XBRL report====
====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.


In this case, the instance document template will be generated according to the facts that already exists in an XBRL Report. The XBRLMapper tool will take the instance document and will prepare an [[XBRL Template File]] for all facts that exists in the instance.
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.


This process generates a template with just the facts that exists in the instance document provided as a parameter. Hint: if the user wants to create an instance document according to the content of one single presentation linkbase, the user can use the XBRLizer tool in order to generate a sample instance document for the presentation tree and then use that file as input for the process of creating the instance document template.
===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.


Steps to produce the initial template file:
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:
# Open Loader Editor tool
* find role types in the DTS (defined in the XBRL spec or in the loaded taxonomies)
# In the "Mapper" menu, select the "New Template from Instance" option
* add new role types to the DTS
# Find the XBRL Report that must be a local file
* delete existing role types (only if they are not defined in the XBRL spec)
# Make sure there is a template file name in the [[Simple Instance Document Template Dialog|dialog to generate a simple instance document template]]. The file name extension should be (*.xbrlt).
# Make sure there is one initial data source in the [[Simple Instance Document Template Dialog|dialog to generate a simple instance document template]] (more data sources can be added later).
# A template will be generated and loaded into the XBRLMapper main window.


===Editing instance document templates===
====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.


The [[XBRL Template File]] page on this wiki explains the format of the template files and how the user can create their own files for more complex mapping scenarios. For complex mapping scenarios the mapping file needs to be edited in an XML Editor.
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.


===Drivers===
====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 vast majority of use cases for mapping can be implemented using one of the generic drivers already developed by Reporting Standard S.L. For special use cases it is always possible to develop specific drivers in Java or .NET programming languages
===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


List of available generic drivers:
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:
* [[Excel data source driver]]
* find arcrole types in the DTS (defined in the XBRL spec or in the loaded taxonomies)
* [[CSV data source driver]]
* add new arcrole types to the DTS
* [[Relational database data source driver]]
* delete existing arcrole types (only if they are not defined in the XBRL spec)
* [[XBRL data source driver]]
* [[Web form data source driver]]


===Running the template===
====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.


The [[Mapper engine|Mapper engine wiki page]] contains an explanation about the two modes of operation:
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.
* as a software component, or
* called from the XBRLmapper GUI


At this stage we assume the user has already finished the creation of an [[XBRL Template File]] as explained in the previous chapters. In general, the process requires following steps:
====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.


# Creating a simple instance document template
===Working with Imported Taxonomies===
# Create some raw data in Excel and map it
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.
# Use the XBRLMapper GUI in order to produce an XBRL report


The process may look hard if it is the first time you do it but remember you are preparing templates and the idea is to reuse the same templates multiple times in the future once the templates and the mapping configuration files are there, the process of producing a new report is much simpler than the first time you go through it.
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.


We continue now with the missing chapters but we are going to link with the relevant chapters also in the specific pages for the drivers.
====Read access====
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.


====Create some raw data in Excel and map====
====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.
If you want to see how other drivers works find the explanation in the specific driver page.
 
First thing you need is the excel XBRL mapping plug-in. This plug-in is able to read the content of an [[XBRL Template File]] and show the user all events suitable to be used from Excel. For installation instruction of the plug-in please contact Reporting Standard.
 
Press the Load... button and open the [[XBRL Template File]]. Then, open the excel spreadsheet you want to map to XBRL. The mapping can be implemented in two ways:
* Using excel names for cells (and forcing the creation of names if names do not exists)
* Using excel cell address of the type Sheet1!C3
 
Once you have both things open, just select on the right the event to map and drag & drop the name to the cell with the data. The mapping will be stored in the Excel driver configuration file. If you have forced the creation of cell names, at the end of the work you'll have to save both, the excel file and the driver configuration files. If the user has not modified excel because mapping has been created only to cell addresses then the user should just save the configuration file for the mapper.
 
The advantage of not storing information in the excel spreadsheet is that the same mapping configuration file can be used with new excel spreadsheets without having to do anything else with the excel file. The excel could be generated by an external tool automatically.
 
The advantage of mapping to cell names rather than cell addresses is that after mapping is finished the user can still add rows and columns to the excel spreadsheet. The mapping will continue working as usual.
 
====Use the XBRLMapper GUI in order to produce an XBRL report====
 
This process is explained in the [[Mapper engine|mapper engine wiki page]].
 
==Moving XBRL data (Loader)==
 
===The definition of the loading events===
 
===Drivers===
 
==Navigate==
[[Main Page]]

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.