XBRLInstance

From XBRLWiki
Revision as of 17:18, 26 June 2009 by Ihr (talk | contribs) (→‎Examples)
Jump to navigationJump to search

[XBRLInstance javadoc page]

Description

A XBRLInstance object represents the content of an XBRL Report. This is:

  • all XBRL facts , and
  • all XBRL contexts, and
  • all XBRL units, and
  • all Footnote Linkbases, and
  • all references to XBRLTaxonomies, XBRLLinkbases, XBRLRoleRef and XBRLArcroleRef required for obtaining the DTS.

How to create an instance of a XBRLInstance object

There are several ways depending on what you are doing:

  • 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 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 constructors. The most commonly used constructor is XBRLInstance(com.ihr.xbrl.om.DTSContainer) that accepts the current DTSContainer as a parameter and allows the user to start adding facts programatically.

See the examples section above.

Remarks

The XBRLInstance object is able to automatically change its content in order to keep consistency during operations with the XBRLInstance. For example, the action of adding a new XBRLFact item to the report may automatically add a new context, a new unit and a new reference to the required taxonomy schema to the report. Deleting the last concept using an XBRLUnit will make the serializable version of the XBRLInstance not to contain the unreferenced unit.

The XBRLInstance object implements the XBRLFactsList interface.

Examples

Creation of a XBRLInstance object from a URL

/**
 * Sample, a new instance 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 SampleReadInstance {

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

Creation of a new instance docyment for a DTS after the DTS has been loaded

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

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

Navigation

Main Page | XBRL API related discussions