Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL...

65
i Interstage XWand XBRL Processor Development Guide All Rights Reserved, Copyright © FUJITSU LIMITED 2003

Transcript of Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL...

Page 1: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

i

Interstage XWandXBRL Processor Development Guide

All Rights Reserved, Copyright © FUJITSU LIMITED 2003

Page 2: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

ii

Preface

Purpose

This manual is the Interstage XWand development guide.

The manual provides an outline of an XBRL processor, and it describes functions supported by theXBRL processor and how to use them. It is intended for developers who use the XBRL processorprovided by Interstage XWand to develop applications that can handle XML documents compliantwith the syntax defined in the Extensible Business Reporting Language (XBRL) 2.0 Specification,2001-12-14 (XBRL 2.0 Specification).

Intended Readers

This manual is intended for developers who use the XBRL processor provided by InterstageXWand to develop user applications that can handle XML documents compliant with the syntaxdefined in the XBRL 2.0 Specification.

Prerequisite Knowledge

Readers are assumed have an understanding of the following reference specifications and relatedreference specifications:

- Extensible Markup Language (XML) 1.0 (Second Edition) W3C Recommendation 6October 2000

- XML Schema Part 0: Primer W3C Recommendation 2 May 2001

- XML Schema Part 1: Structures W3C Recommendation 2 May 2001

- XML Schema Part 2: Datatypes W3C Recommendation 2 May 2001

- Namespaces in XML World Wide Web Consortium 14 January 1999

- XML Path Language (XPath) Version 1.0 W3C Recommendation 16 November 1999

- XML Pointer Language (XPointer) Version 1.0 W3C Candidate Recommendation 11September 2001

- XML Linking Language (XLink) Version 1.0 W3C Recommendation 27 June 2001

- XBRL 2.0 Specification

- Document Object Model (DOM) Level 2 Core Specification Version 1.0

Page 3: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

iii

Organization of This Manual

The manual has the seven chapters and three appendixes listed below.

Chapter 1 XBRL Processor Overview

Chapter 1 provides an overview of the XBRL processor.

Chapter 2 Basic XBRL Processor Information

Chapter 2 provides basic information for use of the XBRL processor.

Chapter 3 Creating and Saving XBRL Data Models

Chapter 3 explains how to create and save documents using XBRL data models.

Chapter 4 Referencing with XBRL Data Models

Chapter 4 explains how to reference document information by using XBRL datamodels.

Chapter 5 Modifying with XBRL Data Models

Chapter 5 explains how to register and modify document information by using XBRLdata models.

Chapter 6 Tutorial

Chapter 6 explains details of using XBRL data models.

Chapter 7 Specifications and Restrictions

Chapter 7 explains the specifications and restrictions to note for use of this product.

Appendix A Pseudo XPath

Appendix A explains pseudo XPath, which is a specification unique to the XBRLprocessor.

Appendix B Tutorial Source Programs

Appendix B provides a complete version of the source code explained in Chapter 6,"Tutorial," and its execution results.

Appendix C Samples of Overridden Documents

Appendix C provides samples of documents with overriding of links.

How to Read This Manual

The manual is the development guide for the following product:

� Interstage XWand XBRL Processor

The manual has been prepared so that readers of it and the related manual can use the XBRLprocessor to develop XBRL document processing applications.

Related Manual

"Fujitsu XBRL Library Java" API Reference

Page 4: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

iv

Export Restrictions

This software product is designed primarily for use in the country to which the software isimported. The software must not be re-exported from the country without authorization from theappropriate government authorities in accordance with the Foreign Exchange and Foreign TradeControl Law of the country. In no event will Fujitsu be liable for foreign government or third-partyclaims for compensation or damages whatsoever arising from the use of the software resulting inany violation of the laws and ordinances of the country or those of the relevant country. Fujitsuassumes no responsibility for any problems or damages arising from such use of the softwareoutside the country. If Fujitsu suffers any damages as a result of a user's violation of the abovelaws, Fujitsu reserves the right to claim compensation from the user.

Abbreviation

In this manual, the Interstage XWand XBRL processor is referred to as:

� XBRL Processor

Trademarks

XBRL is a registered trademark of XBRL.ORG (AICPA).

Java is a trademark or registered trademark of Sun Microsystems, Inc., in the U.S. and othercountries.

Other company names and product names are trademarks or registered trademarks of theirrespective owners.

Company and product names appearing in this manual are trademarks or registered trademarks oftheir respective owners.

The contents of the manual may be revised without prior notice.

The contents of the manual shall not be reproduced in any way or form without the express writtenpermission of Fujitsu Limited.

Fujitsu assumes no responsibility for infringement of any patent rights or other rights of thirdparties arising from use of information in the manual.

Date of Issue

January 2003: First Edition

Page 5: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

v

Contents

1. XBRL PROCESSOR OVERVIEW ....................................................................... 11.1 Purpose .................................................................................................................................... 11.2 Operating Conditions................................................................................................................ 11.3 Terminology .............................................................................................................................. 11.4 References ............................................................................................................................... 2

2. BASIC XBRL PROCESSOR INFORMATION...................................................... 32.1 XBRL Documents ..................................................................................................................... 3

2.1.1 Instance document elements ......................................................................................... 32.1.2 Taxonomy elements ....................................................................................................... 4

2.2 XBRL Data Model..................................................................................................................... 42.2.1 Models common to instance documents and taxonomies............................................. 42.2.2 Model specific to an instance document........................................................................ 92.2.3 Model specific to taxonomies....................................................................................... 10

2.3 Overview of XBRL Processor Processing ...............................................................................11

3. CREATING AND SAVING XBRL DATA MODELS............................................. 133.1 Creating an XBRL Data Model ............................................................................................... 13

3.1.1 Generating an XBRL data model ................................................................................. 133.1.2 Converting an existing XBRL document into an XBRL data model............................. 133.1.3 Creating an XBRL data model from serialized data..................................................... 13

3.2 Saving an XBRL Data Model.................................................................................................. 143.2.1 Saving it as an XBRL document .................................................................................. 143.2.2 Serialization ................................................................................................................. 14

4. REFERENCING WITH XBRL DATA MODELS.................................................. 154.1 Taxonomy ............................................................................................................................... 15

4.1.1 Referring to taxonomy information............................................................................... 164.1.2 Referring to XBRL elements ........................................................................................ 17

4.2 Instance Document ................................................................................................................ 194.2.1 Referring to instance information................................................................................. 194.2.2 Referring to context...................................................................................................... 194.2.3 Referring to values....................................................................................................... 20

4.3 Links ...................................................................................................................................... 244.3.1 Linkbase information.................................................................................................... 254.3.2 Link data and link information ...................................................................................... 254.3.3 Referring to a relation link............................................................................................ 264.3.4 Referring to a resource link.......................................................................................... 274.3.5 Referring to calculation results via calculation links .................................................... 28

4.4 Overriding Links ..................................................................................................................... 294.4.1 Overview ...................................................................................................................... 294.4.2 Creating a process for overriding of information.......................................................... 294.4.3 Reference to overriding of information......................................................................... 30

Page 6: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

vi

5. MODIFYING WITH XBRL DATA MODELS........................................................ 325.1 Adding an Element ................................................................................................................. 325.2 Changing the Contents of an Existing Element...................................................................... 335.3 Deleting an Element ............................................................................................................... 33

6. TUTORIAL ......................................................................................................... 346.1 Creating an XBRL Data Model ............................................................................................... 346.2 Adding Taxonomy and Instance Document Information......................................................... 346.3 Adding Item Element Information and Setting a Value........................................................... 346.4 Adding Links........................................................................................................................... 35

6.4.1 Adding a relation link.................................................................................................... 366.4.2 Adding a resource link ................................................................................................. 36

6.5 Saving an XBRL Data Model.................................................................................................. 37

7. SPECIFICATIONS AND RESTRICTIONS ......................................................... 387.1 Handling of Elements by XBRL Processor............................................................................. 38

7.1.1 Taxonomy-related elements......................................................................................... 387.1.2 Linkbase-related elements........................................................................................... 407.1.3 Instance-related elements............................................................................................ 437.1.4 Common elements....................................................................................................... 47

7.2 Other specifications................................................................................................................ 477.3 Restrictions............................................................................................................................. 48

APPENDIX A PSEUDO XPATH............................................................................. 51

APPENDIX B TUTORIAL SOURCE PROGRAMS ................................................ 52

APPENDIX C SAMPLES OF OVERRIDDEN DOCUMENTS ................................ 57

Page 7: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

XBRL Processor Overview

1

1. XBRL Processor Overview

1.1 PurposeXBRL Processor provides a function for handling instance documents and taxonomies as definedin the XBRL 2.0 Specification.

1.2 Operating ConditionsThe following environments are required for use of XBRL Processor:

� Java execution environment compliant with JRE 1.3.1 or later

� Library that contains Java (TM) API for XML Processing (JAXP) 1.1 and runs in the aboveJava execution environment

1.3 TerminologyThis manual uses the terms defined in the following specification:

� Extensible Business Reporting Language (XBRL) 2.0 Specification, 2001-12-14

Other terms are as follows:

� XBRL documentA general term for instance documents and taxonomies as defined in the XBRL 2.0Specification

� XBRL data modelA unique data model provided by XBRL Processor. An XBRL data model is configuredso that instance documents and taxonomies as defined in the XBRL 2.0 Specification areintegrated to enable handling of data.

� XBRL elementAn XBRL data model element corresponding to item, tuple and other elements describedwith the instance document syntax of the XBRL 2.0 Specification

� Instance informationAn XBRL data model element corresponding to an instance document, whose syntax isdefined in the XBRL 2.0 Specification

� Taxonomy informationAn XBRL data model element corresponding to a taxonomy, whose syntax is defined inthe XBRL 2.0 Specification

Page 8: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

XBRL Processor Overview

2

� Locator informationAn XBRL data model element corresponding to the loc locator-type element describedwith the taxonomy syntax of the XBRL 2.0 Specification

� Entity informationAn XBRL data model element corresponding to the entity sub-element described with theinstance document syntax of the XBRL 2.0 Specification

� PropertyAttributes related to XBRL Processor operation

� Link informationA general term for information on the different types of models of links used in XBRLdocuments

� Linkbase processorThe processor used for linkbase processing. XBRL Processor can have its own functionsfor linkbase processing.

� Pseudo XPathAn XPath expression based on the specification unique to the XBRL processor. When anXBRL element is added to an XBRL data model, pseudo XPath is used to specify wherethe element is to be inserted in an XBRL document. Unlike the XPath expression, pseudoXPath uses a namespace URI and LocalName instead of QName (::= Prefix ':'LocalName). For more information, see the appendix, or refer to the documents about theItem interface in the com.fujitsu.xml.xbrl.datamodel.core package of the Fujitsu XBRLLibrary Java API Reference.

� OverrideA function that overrides links to replace them. See Section 4.4 for more information.

1.4 References� Extensible Business Reporting Language (XBRL) 2.0 Specification 2001-12-14

(http://www.xbrl.org/tr/2001/XBRL-2001-12-14.htm)� XML Schema Part 0: Primer W3C Recommendation 2 May 2001

(http://www.w3.org/TR/2001/REC-xmlschema-0-20010502/)� XML Schema Part 1: Structures W3C Recommendation 2 May 2001

(http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/)� XML Schema Part 2: Datatypes W3C Recommendation 2 May 2001

(http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/)

Page 9: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Basic XBRL Processor Information

3

2. Basic XBRL Processor InformationXBRL Processor models the syntax defined in the XBRL 2.0 Specification so that XBRLdocuments can be used in a Java execution environment.

This chapter covers the following:

1) XBRL document overview

2) Relationships between XBRL documents and XBRL data models

3) XBRL document processing by XBRL Processor

2.1 XBRL DocumentsElements in XBRL documents are classified into instance document elements and taxonomyelements.

2.1.1 Instance document elements

Taxonomies describe relationships of elements making up an instance document. An instancedocument, with its elements and attributes, stores different types of facts as business entities.

The figure below shows the configuration of an instance document. Attributes of individualelements are omitted.

Instance document

Context elements

Different types of sub-elements

Tuple elements

Item elements

Tuple elements

footnoteLink extended-link-type element

Item elements

Different types of sub-elements

Figure 1 Instance document configuration

Page 10: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Basic XBRL Processor Information

4

2.1.2 Taxonomy elements

A taxonomy is a schema document that contains an "element" element that defines the write formatfor an instance document. It also contains a linkbase element that describes the relationships ofelements.

The figure below shows the configuration of a taxonomy. Attributes of individual elements areomitted.

Taxonomy

"element" elements

linkbase elements

import elements

Figure 2 Taxonomy configuration

2.2 XBRL Data ModelAn XBRL data model is its own data model supported by XBRL Processor. It is an integratedmodel of an instance document and one or more taxonomies. Compared with DOMs, XBRL datamodels simplify operations with their use of instance documents and taxonomies based on theXBRL 2.0 Specification.

XBRL data models are classified into the following three categories:

� Models common to instance documents and taxonomies

� Models specific to an instance document

� Models specific to taxonomies

2.2.1 Models common to instance documents and taxonomies

The following two types of models are common to instance documents and taxonomies:

� Core data model

� Common data model

1) Core data modelIn a core data model, root elements represent a variety of facts, which are business entities.The two major aspects of this model are explained below.� XBRL data model

An XBRL data model is configured so that instance documents and taxonomies areintegrated to enable handling of data. It also contains information such as different typesof links that is common to both an instance document and taxonomy.

Page 11: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Basic XBRL Processor Information

5

<<interface>>XBRLDocument

<<interface>>InstanceInformation

<<interface>>TaxonomyInformation

Instance document model

Taxonomy model

XBRL document data model

<<interface>>XBRLElement XBRL elements

· · ·

0..1

*

1

*

<<interface>>LinkData Different types of

link information

*

Figure 3 XBRL data model configuration

� XBRL elementsAn XBRL element integrates the following two items into the model:- Types of elements written in an instance document

Item elements and tuple elements are modeled.

- Definition written in a taxonomy

An "element" element is modeled.

Page 12: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Basic XBRL Processor Information

6

<<interface>>

XBRLElement

<<interface>>Item

<<interface>>Tuple

Item elements

Tuple elements

XBRL elements

<<interface>>OtherElement Other elements

Figure 4 XBRL element configuration

2) Common data modelThe following is modeled by a common data model:� Common characteristics for each document that handles linkbases

An instance document, taxonomy, and linkbase document are included in the model.

<<interface>>

DocumentInformation

<<interface>>LinkbaseInformation

<<interface>>InstanceInformation

Common characteristics for each document that handles linkbases are integrated into a model.

<<interface>>TaxonomyInformation

Document that provides linkbases

Figure 5 Common data model

Page 13: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Basic XBRL Processor Information

7

� Basic information about links

- Information representing individual links that are associated with extended-link-typeelements and their sub-elements is integrated into the model. This is shown in thefollowing figure:

<<interface>>LinkInformation

<<interface>>XBRLArc

<<interface>>XBRLLocator

<<interface>>XBRLXLinkDecl

Provides informationabout an arc-typeelement.

Provides informationabout the loclocator-type element.

Provides information about anextended-link-type element inone XLink declaration.

Provides information onlyon the beginning and end ofa single link included inone XLink declaration.

Figure 6 Basic information about links

- Characteristics common to extended-link-type elements and their sub-elements areintegrated into the model. This is shown in the following figure:

Page 14: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Basic XBRL Processor Information

8

<<interface>>

LinkData

<<interface>>LinkInformation

Common characteristics for each document that handles linkbases are integrated into a model.

Provides information about the footnoteLink extended-link-type element.

<<interface>> FootnoteLinkData

<<interface>> ReferenceLinkData

<<interface>> RelationLinkData

<<interface>> LabelLinkData

<<interface>>CalculationLinkData

<<interface>>DefinitionLinkData

<<interface>>PresentationLinkData

1 1

1 1

1 1

1 *

Provides information about the referenceLink extended-link-type element.

Provides information about the labelLink extended-link-type element.

Provides information about the calculationLink extended-link-type element.

Provides information about the definitionLink extended-link-type element.

Provides information about the presentationLink extended-link-type element.

Figure 7 Extended-link-type element model

Page 15: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Basic XBRL Processor Information

9

2.2.2 Model specific to an instance document

The model specific to an instance document integrates the individual elements defined for theinstance document and their attributes. The figure below shows an outline of the model.

<<interface>>

XBRLDocument

<<interface>>Context

<<interface>>Period

<<interface>>Unit

Context element model

Period element model

Unit element model

<<interface>>Scenario

<<interface>>FootnoteLinkData

Scenario element model

<<interface>>XBRLEntity Entity element

model

<<interface>>Segment Segment

element model

Figure 8 Model specific to instance documents

Page 16: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Basic XBRL Processor Information

10

2.2.3 Model specific to taxonomies

The model specific to taxonomies integrates information associated with links that can be definedin taxonomies and the import function defined in XML Schema. The figure below shows anoutline of the model.

<<interface>>

XBRLDocument

<<interface>>LinkData

<<interface>>TaxonomyInformation

<<interface>>SchemaImport

Figure 9 Model specific to taxonomies

Page 17: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Basic XBRL Processor Information

11

2.3 Overview of XBRL Processor ProcessingXBRL Processor (com.fujitsu.xml.xbrl.processor.XBRLProcessor) provides a function that enablesXBRL document processing with XBRL data models.

XBRL Processor can use the following processes for XBRL data models:

1) Creating an XBRL data modelAn XBRL document is created as an XBRL data model. XBRL data models are created in oneof the following two ways:

- Generating an XBRL data model

- Converting an existing XBRL document into an XBRL data model

2) Saving an XBRL data modelXBRL data models can be saved in either of the following formats:

- XBRL document

- XBRL data model object (serialize)

3) Referring to data in an XBRL documentData in an XBRL document can be referred to as components of an XBRL data model.

4) Modifying data in an XBRL document

Data in an XBRL document can be modified by manipulating components of the correspondingXBRL data model.

To do this, the following two types of options can be specified:

� Options that can be specified in the XBRL Processor propertiesA property name defined in XBRLProperties can be specified using the method shownbelow:- XBRLProcessor.setProperty (String name, Object value)

� Options that can be specified directly in XBRL ProcessorThe following options can be specified:- Add or delete a linkbase processor

XBRLProcessor.addLinkbaseProcessor(LinkbaseProcessor lbProc)XBRLProcessor.removeLinkbaseProcessor(LinkbaseProcessor lbProc)

- Set the error handler

XBRLProcessor.setErrorHandler(XBRLErrorHandler eh)

- Enable or disable caliculationLink

XBRLProcessor.setCalculationLinkEnabled(boolean flg)

- Enable or disable definitionLink

XBRLProcessor.setDefinitionLinkEnabled(boolean flg)

- Enable or disable footnoteLink

XBRLProcessor.setFootnoteLinkEnabled(boolean flg)

- Enable or disable labelLink

XBRLProcessor.setLabelLinkEnabled(boolean flg)

- Enable or disable presentationLink

XBRLProcessor.setPresentationLinkEnabled(boolean flg)

Page 18: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Basic XBRL Processor Information

12

- Enable or disable referenceLink

XBRLProcessor.setReferenceLinkEnabled(boolean flg)

Page 19: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Creating and Saving XBRL Data Models

13

3. Creating and Saving XBRL Data Models

3.1 Creating an XBRL Data Model

3.1.1 Generating an XBRL data model

Use the method shown below to create an XBRL data model. The method generates an XBRL datamodel that does not contain XBRL document information.

- XBRLProcessor.createNewDocument()

3.1.2 Converting an existing XBRL document into an XBRL data model

If an XBRL document is converted into an XBRL data model by XBRL Processor, different typesof operations can be performed with the document.

XBRL Processor supports the methods explained below for reading existing XBRL documents. AnXBRL data model reflecting the contents of an XBRL document can be obtained with thesemethods. Each of the methods can read an XBRL document in the desired format as specified ininput parameter javax.xml.transform.Source. During reading of an XBRL document, it is checkedto verify that it is a valid XBRL document.

1) Reading a taxonomyThe following methods can be used to read a taxonomy as an XBRL data model:

- XBRLProcessor.loadTaxonomy(javax.xml.transform.Source taxSource)

- XBRLProcessor.loadTaxonomy(javax.xml.transform.Source[] taxSource)

2) Reading an instance documentThe following methods can be used to read an instance document as an XBRL data model:

- XBRLProcessor.loadInstance(javax.xml.transform.Source insSource)

- XBRLProcessor.loadInstance(XBRLDocument xbrlDoc, javax.xml.transform.Source insSource)

3.1.3 Creating an XBRL data model from serialized data

An XBRL data model can be saved as an object via serialization, as explained in a subsequentsection. Serialized object data can be read as an XBRL data model using the method shown below.Furthermore, serialized objected data can be read in the desired format as specified in inputparameter java.io.InputStream.

- XBRLProcessor.deserializeDocument(java.io.InputStream inStream)

Page 20: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Creating and Saving XBRL Data Models

14

3.2 Saving an XBRL Data Model

3.2.1 Saving it as an XBRL document

An XBRL data model can be saved as an XBRL document as follows:

1) Saving a taxonomyThe following methods can be used to save a taxonomy obtained from an XBRL data model:

- XBRLProcessor.saveTaxonomy (XBRLDocument xbrlDoc, TaxonomyInformation taxInfo)

- XBRLProcessor.saveTaxonomy (XBRLDocument xbrlDoc, LinkbaseInformation lbInfo, javax.xml.transform.Result result)

- XBRLProcessor.saveTaxonomy (XBRLDocument xbrlDoc, TaxonomyInformation taxInfo, javax.xml.transform.Result result)

2) Saving an instance documentThe following method can be used to save an instance document obtained from an XBRL datamodel:

- XBRLProcessor.saveInstance (XBRLDocument xbrlDoc, javax.xml.transform.Result result)

The prefix of each name (QName) of some elements used in the XBRL document is replaced by anautomatically assigned one. This restriction is based on an XBRL Processor specification. SeeChapter 1, " Specifications and Restrictions," for more information.

3.2.2 Serialization

An XBRL data model can be saved not only as an XBRL document corresponding to the XBRLdata model but also as an object (serialized data). Unlike an XBRL document, serialized datacannot be used as is, but it can be read at higher speeds compared with an XBRL document havingthe same contents because it has already been constructed as an XBRL data model.

- XBRLProcessor.serializeDocument(XBRLDocument xbrlDoc, java.io.OutputStream outStream)

Page 21: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Referencing with XBRL Data Models

15

4. Referencing with XBRL Data ModelsInformation about an XBRL document can be obtained from elements of an XBRL data model.The following three types of elements in XBRL data models can be referenced:

� Taxonomy

� Instance document

� Link

Referencing of each element starts from XBRLDocument. See Section 3.1.2, " Converting anexisting XBRL document into an XBRL data model, and confirm the method for obtaining anXBRLDocument object. The example below assumes that the XBRLDocument object is obtainedas follows:

Example: Obtain an XBRL data model from the document named sample_instance.xml. XBRLDocument xbrlDoc = XBRLProcessor.loadInstance( new StreamSource(new File("sample_instance.xml")));

4.1 TaxonomyIn an XBRL data model, a taxonomy consists of taxonomy information, which is a documentmodel, schema point information, and individual item elements, tuple elements and other elementsthat are XBRL elements defined in the taxonomy.

One XBRL data model can have multiple taxonomies. Furthermore, multiple taxonomies(schemas) can be imported as one taxonomy. The figure below shows the relationship betweenmultiple taxonomies and importing them into an XBRL document.

XBRL document

Instance document

Taxonomy 1

Taxonomy 2' XBRL element <C/>

Taxonomy 2

Import

<A>100</A> XBRL element <A/>

<B>100</B> XBRL element <B/>

<C>100</C> (XBRL element <C/>)

Figure 10 Relationship between an instance document and importing of taxonomies

Page 22: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Referencing with XBRL Data Models

16

4.1.1 Referring to taxonomy information

� Taxonomy information (TaxonomyInformation)Taxonomy information is obtained from XBRLDocument by specifying an index in thefollowing method:

Method XBRLDocument.getTaxonomyInformation(int index)Example: Refer to taxonomy information. [Sample instance document] <?xml version="1.0" encoding="UTF-8"?> <group … xsi:schemaLocation="http://www.fujitsu.com/demo/2002-11-11 taxonomy0.xsd http://www.fujitsu.com/demo/2002-11-18 taxonomy1.xsd"> … [Programming sample] TaxonomyInformation taxInfo0 = xbrlDoc.getTaxonomyInformation(0); TaxonomyInformation taxInfo1 = xbrlDoc.getTaxonomyInformation(1); [Results] taxInfo0.getSystemId() : taxonomy0.xsd taxInfo0.getTargetNamespace() : http://www.fujitsu.com/demo/2002-11-11 taxInfo1.getSystemId() : taxonomy1.xsd taxInfo1.getTargetNamespace() : http://www.fujitsu.com/demo/2002-11-18

Indexes are integers in a range beginning from 0, and they are used to indicate thesequence in which objects are stored. An integer in the following range can be specifiedfor an index: 0 � index � number of objectsFor every reference procedure with the index specified, a procedure for checking thenumber of objects is provided. As a typical example, the following shows a procedure forchecking the number of taxonomy information items:

Example: Check the number of taxonomy information items. [Sample instance document] <?xml version="1.0" encoding="UTF-8"?> <group … xsi:schemaLocation="http://www.fujitsu.com/demo/2002-11-11 sample0.xsd http://www.fujitsu.com/demo/2002-11-18 sample1.xsd"> … [Programming sample] int count = xbrlDoc.getTaxonomyInformationCount(); [Results] count : 2

Before specifying the index, check the number of objects to confirm that the specifiedvalue does not exceed the number of objects.

Page 23: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Referencing with XBRL Data Models

17

� Schema import information (SchemaImport)Information about imported schemas can be obtained by referring to schema importinformation. The method shown below can be used to refer to schema import informationin taxonomy information. A namespace and schema document location can be obtainedfrom the referenced schema import information.

Method TaxonomyInformation.getSchemaImport(int index) SchemaImport.getNamespace() SchemaImport.getSchemaLocation()Example: Refer to the beginning of schema import information. [Sample taxonomy document] <?xml version="1.0" encoding="UTF-8"?> <schema …> <import namespace="http://www.fujitsu.com/demo/2002-11-18" schemaLocation="sample1.xsd"/> … [Programming sample] SchemaImport schema = taxInfo.getSchemaImport(0); String namespace = schema.getNamespace(); String location = schema.getSchemaLocation(); [Results] namespace : http://www.fujitsu.com/demo/2002-11-18 location : sample1.xsd

4.1.2 Referring to XBRL elements

XBRL elements are defined for individual taxonomies. XBRL data models enable XBRL elementsto be collectively referenced using XBRLDocument.

� Referencing with XBRLDocumentXBRL elements can be referenced with XBRLDocument by using an index.

Method XBRLDocument.getElement(int index)Example: Refer to the element at the beginning of the document. [Sample document] <?xml version="1.0" encoding="UTF-8"?> <schema xmlns="http://www.w3.org/2001/XMLSchema" <element id="cash" name="cash" xbrli:balance="debit" type="xbrli:monetaryItemType" substitutionGroup="xbrli:item"/> … [Programming sample] XBRLElement element = xbrlDoc.getElement(0); [Results] element.getId() : cash element.getName() : cash

An XBRL element is an item element, tuple element or other element. The type ofelement can be determined by using the following method to compare it with theXBRLElement constant:

Method XBRLElement.getElementType()Example: Determine the type of XBRL element. if(element.getElementType() = XBRLElement.ELEMENT_TYPE_ITEM) { …(processing)… }

Page 24: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Referencing with XBRL Data Models

18

� Referencing with a name or IDAn XBRL element can be referenced using XBRLDocument by specifying an index. Forease of use, a reference procedure using a specified name or ID is provided.

Method XBRLDocument.getElementByName(TaxonomyInformation taxInfo, String name) XBRLDocument.getElementById(TaxonomyInformation taxInfo,String id);Example: Refer to cash account elements. [Sample document] <?xml version="1.0" encoding="UTF-8"?> <schema xmlns="http://www.w3.org/2001/XMLSchema" <element id="cash" name="cash" xbrli:balance="debit" type="xbrli:monetaryItemType" substitutionGroup="xbrli:item"/> … [Programming sample] XBRLElement element = xbrlDoc.getElementByName(xbrlDoc.getTaxonomyInformation(0),"cash"); [Results] element.getId() : cash element.getName() : cash

If no element with the specified name or ID is found in the specified taxonomy, null isreturned.

� Attribute of item elementOf XBRL elements, item elements have the balance attribute. The balance attribute canbe obtained with a type conversion of such an XBRL element to the item class.

Method Item.getBalance()Example: Obtain the balance attribute. [Sample document] <?xml version="1.0" encoding="UTF-8"?> <schema xmlns="http://www.w3.org/2001/XMLSchema" <element id="cash" name="cash" xbrli:balance="debit" type="xbrli:monetaryItemType" substitutionGroup="xbrli:item"/> … [Programming sample] if(element.getElementType() == XBRLElement.ELEMENT_TYPE_ITEM) { Item item = (Item)element; // Type conversion to Item class String balance = item.getBalance(); // Acquisition of balance attribute } [Results] balance : debit

The above explanation covers only an attribute which is used in item elements. Forinformation about other attributes used by XBRL elements, refer to the Fujitsu XBRLLibrary Java API Reference.Values assigned to item elements by instance documents can be obtained using themethod of the item elements. The next section covers this in detail.

Page 25: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Referencing with XBRL Data Models

19

4.2 Instance DocumentIn an XBRL data model, an instance document consists of instance information(InstanceInformation), which is information about the document, values assigned to XBRLelements defined in taxonomies, and context.

4.2.1 Referring to instance information

To refer to instance information, use the method shown below from XBRLDocument. Because anXBRL document has only one instance document, no index is used.

Method XBRLDocument.getInstanceInformation();Example: Refer to instance information. InstanceInformation insInfo = xbrlDoc.getInstanceInformation();

4.2.2 Referring to context

When a value is assigned to an XBRL element in an XBRL document, general attributes related tothe value, such as the unit and validity term of the value, can be written separately from the value.These attributes are referred to as context. Writing context separately enables reuse of the samegroup of attributes.

� Referring to contextAlthough context is written in an instance document, XBRL Processor enables it to bereferenced from XBRLDocument by using a method with the index specified.

Method XBRLDocument.getContext(int index)Example: [Sample document] <?xml version="1.0" encoding="UTF-8"?> <group …> … <numericContext cwa="true" id="contextMeasureJPY" precision="10"> <entity> <identifier scheme="http://www.fujitsu.com/demo/2002-11-11">demoJPY</identifier> </entity> <period> <instant>2002-11-11</instant> </period> <unit> <measure>ISO4217:JPY</measure> </unit> </numericContext> … [Programming sample] Context context = xbrlDoc.getContext(0); [Results] context.getId() : contextMeasureJPY

Contents are classified as numeric context and nonnumeric context. The type of contextcan be determined by using the following method to compare it with the context constant:

Method Context.getContextType()Example: Check the type of context. if(context.getContextType() == Context.Context_TYPE_NUMERIC) { …(processing)… }

Page 26: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Referencing with XBRL Data Models

20

� Context sub-elementsContext has four sub-elements: entity (XBRLEntity), period, scenario, and unit. Thesefour sub-elements are handled as classes in an XBRL data model.

Method Context.getEntity() Context.getUnit() Context.getScenario() Context.getPeriod()Example: XBRLEntity entity = context.getEntity(); // Entity acquisition Unit unit = context.getUnit(); // Unit acquisition Scenario scenario = context.getScenario(); // Scenario acquisition Period period = context.getPeriod(); // Period acquisition

The entity and period elements are always required. The unit element is required fornumeric context. For more information about individual elements, refer to the FujitsuXBRL Library Java API Reference.

� Context attributesThough nonnumeric context has no attribute other than the id attribute, numeric contexthas the CWA attribute and precision attribute. These attributes can be obtained with atype conversion to the NumericContext class.

Method NumericContext.getCWA() NumericContext.getPrecision()Example: Check the context type, and obtain the attributes of numeric context. [Sample document] <?xml version="1.0" encoding="UTF-8"?> <group …> … <numericContext cwa="true" id="contextMeasureJPY" precision="10"> <entity> <identifier scheme="http://www.fujitsu.com/demo/2002-11-11">demoJPY</identifier> </entity> <period> <instant>2002-11-11</instant> </period> <unit> <measure>ISO4217:JPY</measure> </unit> </numericContext> … [Programming sample] if(context.getContextType() == Context.CONTEXT_TYPE_NUMERIC) { boolean cwa = ((NumericContext)context).getCWA(); // CWA attribute int precision = ((NumericContext)context).getPrecision(); // precision attribute } [Results] cwa : true precision : 10

The above explanation covers only attributes whose use is different between numeric andnonnumeric contexts. For information about other attributes used by contexts, refer to theFujitsu XBRL Library Java API Reference.

4.2.3 Referring to values

A value is data assigned by an instance document to an XBRL element defined in a taxonomy.

� Referring to valuesThree arguments, i.e., an item element among XBRL elements, context, and the pseudo

Page 27: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Referencing with XBRL Data Models

21

XPath string are required to refer to values. Methods for obtaining XBRL elements andcontexts are explained in previous sections. The next sections provide information aboutthe pseudo XPath string. A procedure for referring to values that are all available isshown below:

Method Item.getValues(Context context, String xpath)Example: Obtain values. (1) [Sample document] <?xml version="1.0" encoding="UTF-8"?> <group …> <p0:Name nonNumericContext="contextPeriod" xml:lang="ja">FujitsuKabushikigaisya</p0:Name> <p0:Name nonNumericContext="contextPeriod" xml:lang="en">Fujitsu Ltd.</p0:Name> [Programming sample] String xpath = "/{http://www.xbrl.org/2001/instance}:group[1]"; java.util.Enumeration enum = item.getValues(context, xpath);

Because more than one value may be assigned to an item, an enumeration iterator is usedfor referencing. The iterator is a structure used to refer to a group of objects in a givensequence. XBRL Processor uses the iterator to refer to elements when the referencetargets and sequence can be resolved in XBRL Processor processing. In the aboveexample, the reference values are narrowed down by context and pseudo XPath string. Aprocedure for actually determining values (Value class) using the iterator is shown below:

Example: Obtain values. (2) [Programming sample] String xpath = "/{http://www.xbrl.org/2001/instance}:group[1]"; java.util.Enumeration enum = item.getValues(context, xpath); while(enum.hasMoreElements()){ Value value = (Value)enum.nextElement(); } [Results] value.getSpecified() First : Fujitsu Kabushikigaisya value.getSpecified() Second : Fujitsu Ltd.

� Pseudo XPathThe pseudo XPath string required for quoting values from an XBRL data model can bedirectly specified or obtained it from the data model.In order to specify pseudo XPath directly, it must be written as a character stringconforming to the instance document structure. For information on how to write it, seethe example in Appendix A, "Pseudo XPath."Direct specification of pseudo XPath is mainly used for adding values. XBRL elementscan be specified clearly when values are added. For value referencing, however, thedocument structure may be unknown or the items to be handled may be undefined duringprocessing. When an XBRL data model is used, a list of pseudo XPath strings can bereferred to as an iterator if the item element and context for the reference value are known.The procedure is shown below.

Method Item.getXPaths(Context context)Example: Obtain a list of pseudo XPath strings. [Sample document] <?xml version="1.0" encoding="UTF-8"?> <group …> <p0:Name nonNumericContext="contextPeriod" xml:lang="ja">FujitsuKabushikigaisya</p0:Name> <p0:Name nonNumericContext="contextPeriod" xml:lang="en">Fujitsu Ltd.</p0:Name> [Programming sample] java.util.Enumeration enum = item.getXPaths(context); while(enum.hasMoreElements()){ String xpath = (String)enum.nextElement(); }

Page 28: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Referencing with XBRL Data Models

22

[Results] xpath First: /{http://www.xbrl.org/2001/instance}:group[1]

This procedure can refer to values without directly writing pseudo XPath strings.Processing to obtain values can be connected to the above procedure as follows:

Example: Refer to values by obtaining pseudo XPath strings from a data model. java.util.Enumeration enum = item.getXPaths(context); while(enum.hasMoreElements()){ String xpath = (String)enum.nextElement(); java.util.Enumeration enum2 = item.getValues(context, xpath); while(enum2.hasMoreElements()){ Value value = (Value)enum2.nextElement(); …(processing)… } }

� Value typeValues are numeric or nonnumeric. The type of value can be checked by using thefollowing method to compare a value with the Value constant:

Method Value.getValueType()Example: Check the type of value. if(value.getValueType() = Value.VALUE_TYPE_NUMERIC) { …(processing)… }

A nonnumeric value can be converted into the NonNumericValue type to obtain thelanguage attribute of the value.

Method NonNumericValue. getLanguage()Example: Obtain the language attributes of nonnumeric values. [Sample document] <?xml version="1.0" encoding="UTF-8"?> <group …> <p0:Name nonNumericContext="contextPeriod" xml:lang="ja">FujitsuKabushikigaisya</p0:Name> <p0:Name nonNumericContext="contextPeriod" xml:lang="en">Fujitsu Ltd.</p0:Name> [Programming sample] java.util.Enumeration enum = item.getXPaths(context); while(enum.hasMoreElements()){ String xpath = (String)enum.nextElement(); java.util.Enumeration enum2 = item.getValues(context, xpath); while(enum2.hasMoreElements()){ Value value = (Value)enum2.nextElement(); if(value.getValueType() == Value.VALUE_TYPE_NONNUMERIC) { String lang = ((NonNumericValue)value).getLanguage(); } } } [Results] lang First : ja lang Second : en

However, the language attribute is not always defined. For example, a business entitysuch as the date is a nonnumeric value, but the language attribute may not be defined for itbecause language has no bearing on it.A numeric value can be converted into the NumericValue type to obtain a calculatedvalue.

Page 29: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Referencing with XBRL Data Models

23

Method NumericValue.getCalculated()Example: Obtain a calculated value. [Sample document] <?xml version="1.0" encoding="UTF-8"?> <group …> <p0:cash numericContext="contextJPY">10000</p0:Name> <p0:cash numericContext="contextUSD">80</p0:Name> … [Programming sample] java.util.Enumeration enum = item.getXPaths(context); while(enum.hasMoreElements()){ String xpath = (String)enum.nextElement(); java.util.Enumeration enum2 = item.getValues(context, xpath); while(enum2.hasMoreElements()){ Value value = (Value)enum2.nextElement(); if(value.getValueType() == Value.VALUE_TYPE_NUMERIC) { java.math.BigDecimal calc = ((NumericValue)value).getCalculated(); } } } [Results] calc First: 10000.00000 * Only one value with the same context can be defined for a numeric value. Because context must be specified to obtain a value, only one value can be obtained in this example.

A procedure for actual calculation is described in a subsequent section.

� Contents of a valueThe actual contents of a value are obtained by using the value.getSpecified() method. Thecontents are referred to as a character string.

Method Value.getSpecified()Example: String strValue = value.getSpecified();

Page 30: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Referencing with XBRL Data Models

24

4.3 LinksLinks are specifications for extending XBRL document functions. XBRL documents have afunction for describing the relationships of XBRL elements and a function for specifying a resourcefor an XBRL element. Links are currently used to implement these two functions.

Links are classified into two categories: tree-structured links and map-structured links. A tree-structured link is used to describe the relationships of XBRL elements. When resources arespecified, lists are configured as a map of resources for XBRL elements. The figures belowillustrate the two types of links.

Linkbase document XBRL document XBRL element <A/> XBRL element <B/> XBRL element <C/> XBRL element <D/> ···

Link data 1 XBRL element <A/>

Link data 2 XBRL element <B/>

Link data 3 XBRL element <C/>

Link data 4 XBRL element <D/>

Figure 11 Relation links

Linkbase document XBRL document

XBRL element <A/> XBRL element <B/> XBRL element <C/>

XBRL element <D/> ···

Link data 1 Resources XBRL element <A/> XBRL element <B/> XBRL element <C/>

Aa

Bi

Cu

Figure 12 Resource links

Page 31: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Referencing with XBRL Data Models

25

4.3.1 Linkbase information

A linkbase document provides a taxonomy or instance document with a link structure and data.Information about links can be stored as separate documents from taxonomy and instancedocuments (depending on the type of link). Information about linkbase documents is representedas linkbase information (LinkbaseInformation).

� Referring to linkbase informationThe DocumentInformation class, which is the parent class of taxonomy, linkbase, andinstance information, provides a procedure for referring to linkbase information whenXBRL Processor is used. To refer to linkbase information, use the method that isappropriate for the type of linkbase information for taxonomy, linkbase, or instanceinformation.

Method DocumentInformation.getPresentationLinkbaseInformation(int index) DocumentInformation.getReferenceLinkbaseInformation(int index) DocumentInformation.getLabelLinkbaseInformation(int index) DocumentInformation.getDefinitionLinkbaseInformation(int index) DocumentInformation.getCalculationLinkbaseInformation(int index)Example: [Sample document] <?xml version="1.0" encoding="UTF-8"?> <schema …> <annotation> <appinfo> <xbrll:linkbaseRef xlink:type="simple" xlink:actuate="onRequest" xlink:arcrole="http://www.w3.org/1999/xlink/properties/linkbase" xlink:href="link_presentation.xml" xlink:role="http://www.xbrl.org/linkprops/linkRef/presentation"> presentationLink </xbrll:linkbaseRef> … </appinfo> </annotation> … [Programming sample] LinkbaseInformation lbInfo = taxInfo.getPresentationLinkbaseInformation(0); [Results] lbInfo.getSystemId() : link_presentation.xml

4.3.2 Link data and link information

� Link data (LinkData)LinkData is the node entities that constitute a link. Its primary function is to store XBRLelements and references to other link data and resource objects. The link data handlingprocedure itself becomes a reference to a link. See the next section for information on thereference procedure.

� Link information (LinkInformation)LinkInformation represents the relationships between other link data and resource objectsstored in LinkData. This information is required for configuring a link or determining thetype of connection to a link. See the next section for information on the referenceprocedure.

� Obtaining XLink declaration information (XBRLXLinkDecl)XLink declaration information is an interface for generating link information. It is alwaysrequired for generating link information. To obtain XLink declaration information, usethe following method for the DocumentInformation class (i.e., the TaxonomyInformationor InstanceInformation class):

Page 32: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Referencing with XBRL Data Models

26

Method DocumentInformation.createXLinkDecl()Example: XBRLXLinkDecl xlinkDecl = taxInfo.createXLinkDecl();

4.3.3 Referring to a relation link

To refer to an XBRL element according to specified relationships, link data is referenced before theXBRL element is referenced based on the link data.

� Referring to link dataTo refer to the node entity of a relation link, specify an index with XBRLDocument.

Method XBRLDocument.getRootPresentationLinkData(int index) XBRLDocument.getRootCalculationLinkData(int index) XBRLDocument.getRootDefinitionLinkData(int index)Example: [Sample document] link_presentaion.xml <?xml version="1.0" encoding="UTF-8"?> <linkbase …> <presentationLink xlink:type="extended"> <loc xlink:type="locator" xlink:href="demo3_balancesheet.xsd#Document" xlink:label="src" xlink:role="http://www.xbrl.org/linkprops/locator/root"/> … </presentationLink> … [Programming sample] PresentationLinkData rootLinkData = xbrlDoc.getRootPresentationLinkData(0);

Although a relation link has a tree structure, only the node at the root of the tree can bereferenced from the XBRLDocument object. Subnodes under the root can be referencedusing the getChild(int index) method for each piece of link data.

Example: Refer to subnodes. [Sample document] <?xml version="1.0" encoding="UTF-8"?> <linkbase …> <presentationLink xlink:type="extended"> <loc xlink:type="locator" xlink:href="demo3_balancesheet.xsd#Document" xlink:label="src" xlink:role="http://www.xbrl.org/linkprops/locator/root"/> <loc xlink:type="locator" xlink:href="demo3_balancesheet.xsd#Company" xlink:label="dest"/> … </presentationLink> <presentationLink xlink:type="extended"> <loc xlink:type="locator" xlink:href="demo3_balancesheet.xsd#Document" xlink:label="src" xlink:role="http://www.xbrl.org/linkprops/locator/root"/> <loc xlink:type="locator" xlink:href="demo3_balancesheet.xsd#Title" xlink:label="dest"/> … </presentationLink> … [Programming sample] java.util.Enumeration enum = rootLinkData.getOrderedChildren(); while(enum.hasMoreElements()){ PresentationLinkData pLinkData = (PresentationLinkData)enum.nextElement(); }

The above example uses the getOrderedChildren method instead of the getChild method.The getOrderedChildren method is a method specific to presentation links and used forresolving the presentation order of overriding and sub-elements. Overriding processing isdescribed in a subsequent section.

Page 33: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Referencing with XBRL Data Models

27

� Referring to linked elementsThe following example refers to an element for which a link is represented by referencedlink data.

Method RelationLinkData.getElement()Example: [Sample document] <?xml version="1.0" encoding="UTF-8"?> <linkbase …> <presentationLink xlink:type="extended"> <loc xlink:type="locator" xlink:href="demo3_balancesheet.xsd#Document" … [Programming sample] XBRLElement element = pLinkData.getElement(); [Results] element.getId() : Document

� Referring to link informationA relation link represents the relationships of elements as link information. Example ofimportant attributes in the relationships are order in terms of presentation links and weightin terms of calculation links. The figure below shows a procedure for obtaining the orderattribute of a presentation link.

Method PresentationArc.getOrder() CalculationArc.getWeight()Example: Obtain the order attribute of a presentation link. LinkInformation linkInfo = pLinkData.getResolvedLinkInformation(); XBRLArc arc = linkInfo.getArc(); if(arc.getArcType() == XBRLArc.ARC_TYPE_PRESENTATION){ PresentationArc presArc = (PresentationArc)arc; double order = presArc.getOrder(); }

4.3.4 Referring to a resource link

To refer to the resource specified for an XBRL element, refer to link data and the XBRL elementbefore obtaining the resource assigned to the XBRL element from the referenced link data.

� Referring to link dataXBRL Processor assumes each XBRLDocument has one resource link node entity. Thelabel, reference, and footnote links can be referenced using the respective methods.

Method XBRLDocument.getLabelLinkData() XBRLDocument.getFootnoteLinkData() XBRLDocument.getReferenceLinkData()Example: LabelLinkData labelLink = xbrlDoc.getLabelLinkData(); FootnoteLinkData footLink = xbrlDoc.getFootnoteLinkData(); ReferenceLinkData refLink = xbrlDoc.getReferenceLinkData();

Page 34: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Referencing with XBRL Data Models

28

� Referring to resourcesLink data is referenced for resources allocated to elements. These elements are assumedto have already been obtained individually as a variable name element.

Method LabelLinkData.getResolvedLabels(XBRLElement element) ReferenceLinkData.getResolvedReferences(XBRLElement element) LabelLinkData.getResolvedLabels(XBRLElement element)Example: java.util.Enumeration enum = labelLink.getResolvedLabels(element); while(enum.hasMoreElements()){ Label label = (Label)enum.nextElement(); }

� Using resourcesResource information (value and language attribute) is obtained from the resource class.

Method Label.getValue() Label.getLanguage()Example: Obtain labels written in Japanese. [Sample document] <label xlink:type="resource" xlink:label="label" xml:lang="ja">Syamei</label> [Programming sample] if(label.getLanguage().equals("ja")){ String labelValue = label.getValue(); // Reference to label value String lang = label.getLanguage(); // Reference to label language attribute } [Results] labelValue : Syamei lang : ja

4.3.5 Referring to calculation results via calculation links

As explained in a previous section, calculation results can be referenced via a calculation link byusing the getCalculated method with a value assigned to a numeric item (NumericValue). Thevalue should be explicitly assigned or automatically calculated with the following procedure:

Method CalculationLinkData.calculate()

Calculations are automatically made for each context to which a value belongs. Calculations arealso automatically made for the subnodes of the node for which the calculate method is executed.Thus, if values for all calculation links in an XBRL data model are to be calculated, the abovemethod need only be applied to the root node. An example is shown below.:

Example: Calculate all calculation links of a document. int count = xbrlDoc.getRootCalculationLinkDataCount(); for(int i=0; i<count; i++){ xbrlDoc.getRootCalculationLinkData(i).calculate(); }

Page 35: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Referencing with XBRL Data Models

29

4.4 Overriding Links

4.4.1 Overview

An XBRL document enables different types of link information to be assigned to a single link. Italso enables multiple links that are assumed to be identical to one another to be defined. Thesedefinitions are not restricted to the same document, such as a taxonomy or linkbase document.Links and link information for different documents can be assigned.

Based on the above specifications, once links are created, they can be replaced without deletion ormodification of their contents. This function is referred to as "override." The override functionenables flexible extension of XBRL documents. For example, link information containsinformation such as whether link traversal is enabled, the element presentation order, andmultipliers used for item calculations. The presentation order and calculation expressions can bechanged according to the phase in which CBRL documents are used.

* Presentation order 3 is given as the link information indicated by the solid line.

Link data A

XBRL element <A/>

Link data B

XBRL element <B/>

Link information

Presentation order 0Presentation order 2

Presentation order 3

Figure 13 Overriding of link information

Different labels having the same language, ja, are specified for element A. The label indicated by solid lines is given priority based on the priority attribute in link information.

Link data Language ResourceXBRL element <A/> ja “sample”

Link data Language ResourceXBRL element <A/> ja “sanpuru”

Figure 14 Overriding of the same link

4.4.2 Creating a process for overriding of information

The following shows an example of creating a process for overriding of information in an XBRLProcessor data model:

Page 36: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Referencing with XBRL Data Models

30

Example: Create a process for overriding of information:

//Obtain the link data to be overridden.PresentationLinkData parentLink = xbrlDoc.getRootPresentationLinkData(0);PresentationLinkData childLink = parentLink.getChild(0);

//Obtain existing link information.LinkInformation oldLinkInfo = parentLink.getResolvedLinkInformation(childLink);

//Obtain the interface that represents XLink declaration information about each type of link.//Specify different taxonomies to store information in separate taxonomies.XBRLXLinkDecl xDecl = taxInfo2.getPresentationLinkbaseInformation(0).createXLinkDecl();//Create an arc to represent the behavior of a link from parent to child.PresentationArc arc =(PresentationArc)xDecl.createArc(XBRLArc.ARC_TYPE_PRESENTATION);arc.setArcRole(RelationArc.ARC_ROLE_PARENT_CHILD);//Create an arc to represent the behavior of a link from child to parent.PresentationArc cArc =(PresentationArc)xDecl.createArc(XBRLArc.ARC_TYPE_PRESENTATION);cArc.setArcRole(RelationArc.ARC_ROLE_CHILD_PARENT);//Create a locator.XBRLLocator srcLoc = xDecl.createLocator();//Assign an arbitrarily defined label to the locator.srcLoc.setLabel("src");//Create a locator for the link reference destination.XBRLLocator destLoc = xDecl.createLocator();//Assign an arbitrarily defined label to the locator.destLoc.setLabel("dest");

//Change the presentation order.PresentationArc oldArc = (PresentationArc)oldLinkInfo.getArc(); //Obtain the old presentationorder.arc.setOrder(oldArc.getOrder() + 1); //Raise the order by one step.cArc.setOrder(oldArc.getOrder() + 1); //Raise the order by one step.//Change the priority of link.arc.setPriority(oldArc.getPriority() + 1); //Raise the priority by one level.cArc.setPriority(oldArc.getPriority() + 1); //Raise the priority by one level.

//Create link information.LinkInformation newLinkInfo = parentLink.createLinkInformation(arc, cArc, srcLoc, destLoc);

//Register the new link information from parent link data to child link data.parentLink.addLinkInformation(childLink, newLinkInfo);

4.4.3 Reference to overriding of information

XBRL Processor provides two types of procedures: one is a reference procedure that resolves theoverriding of links; the other is a reference procedure that does not resolve the overriding of links.In an XBRL data model, the priority of link information (or the order of associated taxonomyinformation in cases of the same priority) is used to resolve the overriding of links for a referenceprocedure. A method used to resolve the overriding of information is shown below:

� Method used to resolve the overriding of link information:

- RelationLinkData.getResolvedLinkInformation()

� General relation links:

- RelationLinkData.getResolvedChildren()

- RelationLinkData.getResolvedParents()

� Individual methods for resolving the overriding of relation links:

- PresentationLinkData.getOrderedChildren()

- CalculationLinkData.calculate()

Page 37: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Referencing with XBRL Data Models

31

� Individual methods for resolving the overriding of resource links:

- LabelLinkData.getResolvedLabels()

- ReferenceLinkData.getResolvedReferences()

- FootnoteLinkData.getResolvedFootnotes()Appendix C, "Samples of Overridden Documents," provides examples of reference to XBRL documentscontaining the overriding of information.

Page 38: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Modifying with XBRL Data Models

32

5. Modifying with XBRL Data ModelsInformation about XBRL documents can be changed by manipulating elements of thecorresponding XBRL data model.

Changes to an XBRL data model are classified into the following three categories:

1) Adding an element

2) Changing the contents of an existing element

3) Deleting an element

5.1 Adding an ElementIn an XBRL data model, objects that contain individual elements provide basic creation methodsalong with setting and addition methods for subordinate elements. Each created element provides asetting method for itself.

The figure below shows the basic flow for adding new elements to an XBRL data model.

: User application :A

createB()

High-orderelement

:B Low-orderelementsetAny()

setB()

Figure 15 Basic flow for adding new elements to an XBRL data model

For example, InstanceInformation, which provides instance document information and is a low-order element as viewed from XBRLDocument, can be created and set as follows:

1) Create an InstanceInformation instance using XBRLDocument.createInstanceInformation().

2) Specify settings of the InstanceInformation instance created in step 1).

3) Using XBRLDocument.setInstanceInformation(), set the InstanceInformation instance as anXBRLDocument instance.

Page 39: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Modifying with XBRL Data Models

33

5.2 Changing the Contents of an Existing ElementTo change a specific item in an XBRL document, change the settings of elements in thecorresponding XBRL data model. For example, to change the value of the balance attribute of anitem element, use the following method from the applicable item instance to change the settings:

� Item.setBalance(String balance)

5.3 Deleting an ElementTo delete a specific item from an XBRL document, delete an element in the corresponding XBRLdata model.

Common data models of instance documents and taxonomies need not be distinguished for thispurpose. For example, to delete the item element in an instance document defined by an "element"element of the associated taxonomy simultaneously with the "element" element, delete thecorresponding XBRLElement instance from its upper-level element XBRLDocument instance,using the following method:

� XBRLDocument.removeElement(XBRLElement elem)

Page 40: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Tutorial

34

6. TutorialThis chapter explains how to use XBRL Processor as follows and provides examples:

1) Using XBRL Processor to create an XBRL data model

2) Adding taxonomy and instance document information to an XBRL data model

3) Adding item element information to an XBRL data model and setting a value

4) Adding a link to an XBRL data model

5) Saving a taxonomy and an instance document from an XBRL data model, and serializing anXBRL document model

6.1 Creating an XBRL Data ModelUsing XBRLProcessor, create an XBRL data model (XBRLDocument). The following creates anXBRL data model that has no information:

XBRLProcessor xbrlProc = new XBRLProcessor();// Create an XBRL document data model.XBRLDocument xbrlDoc = xbrlProc.createNewDocument();

6.2 Adding Taxonomy and Instance Document InformationTaxonomy information and instance document information in an XBRL data model are representedby TaxonomyInformation and InstanceInformation, respectively. An instance can be added tothese instances as follows:

1) Creating with XBRLDocument

2) Execution of necessary settings

3) Addition to XBRLDocument

// Create and specify taxonomy information.TaxonomyInformation taxInfo = xbrlDoc.createTaxonomyInformation();taxInfo.setSystemId(taxSysId);taxInfo.setTargetNamespace("http://foo.nowhere/namespace/target");xbrlDoc.addTaxonomyInformation(taxInfo);// Create and specify instance information.InstanceInformation insInfo = xbrlDoc.createInstanceInformation();insInfo.setSystemId(insSysId);xbrlDoc.setInstanceInformation(insInfo);

6.3 Adding Item Element Information and Setting a Value1) Adding XBRL elements

In an XBRL data model, Item represents an item element together with an "element" element.For Item, XBRLDocument provides a creation method in a model common to an instancedocument and taxonomy. Only information to be reflected in a taxonomy is created at thisstage.

Page 41: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Tutorial

35

// Add item elements.Item item = (Item)xbrlDoc.createElement(taxInfo, XBRLElement.ELEMENT_TYPE_ITEM);item.setId("sample_id");item.setName("sample_name");item.setType(Item.XBRL_INSTANCE_NS_URI, Item.TYPE_MONETARY_ITEM);xbrlDoc.addElement(item);

Item item2 = (Item)xbrlDoc.createElement(taxInfo, XBRLElement.ELEMENT_TYPE_ITEM);item2.setId("sample_id2");item2.setName("sample_name2");item2.setType(Item.XBRL_INSTANCE_NS_URI, Item.TYPE_MONETARY_ITEM);xbrlDoc.addElement(item2);

2) Adding item element information

Add item element information.

At this point, add the item elements listed below to the location immediately following the rootelement (group[1]) of the instance document.

Use pseudo XPath to determine where each of the item elements is to be inserted in the instancedocument.

� Numeric value of 100 with a unit from ISO4217:JPY

� Date indicating December 14, 2001

� Defining identifier as "www.samp.org" in "SAMP ", for an entity sub-element

// Add values.Context context = xbrlDoc.createContext(insInfo, Context.CONTEXT_TYPE_NUMERIC);context.setId("i1");XBRLEntity entity = context.createEntity();entity.setIdentifier("SAMPLE");entity.setScheme("sample.nowhere");context.setEntity(entity);Instant instant = (Instant)context.createPeriod(Period.PERIOD_TYPE_INSTANT);instant.setDate("2001-12-14");context.setPeriod(instant);Measure measure = (Measure)context.createUnit(Unit.UNIT_TYPE_MEASURE);measure.setValue("ISO4217:JPY");context.setUnit(measure);xbrlDoc.addContext(context);

String xpath = "/{" + Item.XBRL_INSTANCE_NS_URI + "}:group[1]";

Value value = item.createValue(Value.VALUE_TYPE_NUMERIC);value.setSpecified("100");item.addValue(context, xpath, value);

6.4 Adding LinksAdd links.

The procedure for adding a relation link differs from that for adding a resource link. For therelation link, the registration procedure differs between the root link and sublinks. If only the rootlink exists, creation of a link entity is omitted.

Page 42: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Tutorial

36

6.4.1 Adding a relation link

// Add a link.// Register a presentation link reference.LinkbaseInformation lbInfo = taxInfo.createLinkbaseInformation();lbInfo.setSystemId("link_presentaion.xml");taxInfo.addPresentationLinkbaseInformation(lbInfo);// Create link data.PresentationLinkData pLink = (PresentationLinkData)xbrlDoc.createLinkData( LinkData.LINK_DATA_TYPE_PRESENTATION);// Specify an element in the link nodepLink.setElement(item);// Register link data for the root link.xbrlDoc.addRootPresentationLinkData(pLink);

//Create link data containing a link registration element.PresentationLinkData childLink = (PresentationLinkData) xbrlDoc.createLinkData( LinkData.LINK_DATA_TYPE_PRESENTATION);childLink.setElement(item2);

pLink.addChild(childLink);XBRLXLinkDecl xDecl = lbInfo.createXLinkDecl();PresentationArc arc =(PresentationArc)xDecl.createArc(XBRLArc.ARC_TYPE_PRESENTATION);arc.setArcRole(RelationArc.ARC_ROLE_PARENT_CHILD);PresentationArc cArc =(PresentationArc)xDecl.createArc(XBRLArc.ARC_TYPE_PRESENTATION);cArc.setArcRole(RelationArc.ARC_ROLE_CHILD_PARENT);arc.setOrder(10);cArc.setOrder(10);

XBRLLocator srcLoc = xDecl.createLocator();if (xbrlDoc.containsRootPresentationLinkData(pLink)){ srcLoc.setRole(XBRLLocator.ROLE_ROOT);}srcLoc.setLabel("src");XBRLLocator destLoc = xDecl.createLocator();destLoc.setLabel("dest");LinkInformation linkInformation =parentLink.createLinkInformation(arc, cArc, srcLoc, destLoc);pLink.addLinkInformation(childLink, linkInformation);

6.4.2 Adding a resource link

// Register a label link reference.LinkbaseInformation lbInfo2 = taxInfo.createLinkbaseInformation();lbInfo2.setSystemId("link_label.xml");taxInfo.addLabelLinkbaseInformation(lbInfo2);

LabelLinkData lLink = (LabelLinkData) xbrlDoc.createLinkData(LinkData.LINK_DATA_TYPE_LABEL);xbrlDoc.setLabelLinkData(lLink);

//Create a label source.Label label = labelLinkData.createLabel();label.setLanguage("ja");label.setValue("TEST");

//Add the link destination resource to link data.lLink.addLabel(item, label);

//Create link information.xDecl = lbInfo2.createXLinkDecl();

Page 43: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Tutorial

37

LabelArc arc2 = (LabelArc)xDecl.createArc(XBRLArc.ARC_TYPE_LABEL);arc2.setArcRole(LabelArc.ARC_ROLE_ELEMENT_LABEL);LabelArc cArc2 = (LabelArc)xDecl.createArc(XBRLArc.ARC_TYPE_LABEL);cArc2.setArcRole(LabelArc.ARC_ROLE_LABEL_ELEMENT);srcLoc = xDecl.createLocator();srcLoc.setLabel("element");destLoc = xDecl.createLocator();destLoc.setLabel("label");LinkInformation linkInformation =

lLink.createLinkInformation(arc2, cArc2, srcLoc, destLoc);

//Specify link information.lLink.setLinkInformation(item, label, linkInformation);

6.5 Saving an XBRL Data ModelSave taxonomies, linkbase documents, and instance documents.

// Save taxonomies, linkbase documents, and instance documents.try { xbrlProc.saveTaxonomy(xbrlDoc, taxInfo, null); xbrlProc.saveTaxonomy(xbrlDoc, lbInfo, null); xbrlProc.saveTaxonomy(xbrlDoc, lbInfo2, null); xbrlProc.saveInstance(xbrlDoc, null);} catch (java.io.IOException e) { System.out.println("save error.");} catch (org.xml.sax.SAXException e) { System.out.println("save error.");} catch (javax.xml.transform.TransformerException e) { System.out.println("save error.");} catch (XBRLProcessorException e) { System.out.println("save error.");}

Serialize an XBRL data model in preparation for repeated processing of the same instancedocuments and taxonomies.

// Serialize an XBRL document data model.try { FileOutputStream stream = new FileOutputStream("serialize.dat"); xbrlProc.serializeDocument(xbrlDoc, stream);} catch (Exception e) { System.out.println("serialize error.");}

For more information, see all relevant source programs and execution results shown in Appendix B,"Tutorial Source Programs."

Page 44: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Specifications and Restrictions

38

7. Specifications and RestrictionsThis chapter explains XBRL Processor specifications and restrictions. For other specifications,refer to the Fujitsu XBRL Library Java API Reference.

7.1 Handling of Elements by XBRL ProcessorWhen XBRL Processor handles XBRL documents, it may automatically supplement, modify,ignore, or abandon document information. This is described in more detail in the followingsections.

7.1.1 Taxonomy-related elements

1) All taxonomy-related elements(Elements belonging to namespace http://www.w3.org/2001/XMLSchema)� Reading from a file

- Abandons namespace prefix information.

- Ignores user-defined attributes.

� Writing to a file

- Assigns no namespace prefix (belongs to the default namespace).

2) schema element

� Reading from a file

- Deletes any white spaces before and after the targetNamespace attribute value.

- Returns an error if the targetNamespace attribute is not found.

� Writing to a file

- Outputs the following namespace declarations:

xmlns="http://www.w3.org/2001/XMLSchema" xmlns:xbrli="http://www.xbrl.org/2001/instance" xmlns:xbrll="http://www.xbrl.org/2001/XLink/xbrllinkbase" xmlns:xlink="http://www.w3.org/1999/xlink"

- Outputs sub-elements in sequence from linkbaseRef to import and then "element."

- Outputs targetNamespace attribute value after URI encoding.

3) "element" element

� Reading from a file

- Deletes any white spaces before and after the name attribute value.

- Deletes any white spaces before and after the id attribute value.

- Deletes any white spaces before and after the type attribute value.

- Deletes any white spaces before and after the substitutionGroup attribute value.

- Deletes any white spaces before and after the balance attribute value.

- Deletes any white spaces before and after the abstract attribute value.

- The name attribute is required. XBRL Processor ignores the element which has no name

Page 45: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Specifications and Restrictions

39

attribute (posts a warning to the error handler).

- Appends the element whose substitutionGroup attribute value is not xbrli:item /xbrli:tuple to the XBRL data model as an other element (OtherElement).

- Ignores any attribute other than the name, id, type, substitutionGroup, balance andabstract attributes.

- Abandons namespace prefix information in the attribute value (QName) of the type orsubstitutionGroup attribute.

- Ignores any element definitions other than the global element definitions.

- Ignores any sub-elements other than the annotation element.

� Writing to a file

- Uses ‘xbrli’ as the namespace prefix in the attribute value (QName) of the type andsubstitutionGroup attributes, or uses ‘useri’ if the attribute value belongs to a namespaceother than http://www.xbrl.org/2001/instance. Also, XBRL Processor adds thenamespace declaration attribute related to the namespace to which it belongs to an"element" element. It outputs the namespace declaration attribute value after URIencoding.

� Example of reading -> writing

[before reading]<xsd:element name="foo" id="foo" type="foo:userItemType" substitutionGroup="xbi:item" xmlns:foo ="http://www.user.org/2001/sample"/>[after writing]<element name="foo" id="foo" type="useri:userItemType" substitutionGroup="xbrli:item" xmlns:useri="http://www.user.org/2001/sample"/>

4) annotation element

� Reading from a file

- Ignores any annotation element that does not have a linkbaseRef element as a sub-element or that is not immediately under an "element" element.

� Writing to a file

- Outputs only the annotation element that has a linkbaseRef element as a sub-element orthat is immediately under an "element" element.

5) appinfo element

� Reading from a file

- Ignores any apinfo element that does not have a linkbaseRef element as a sub-element.

� Writing to a file

- Outputs only the appinfo element that has a linkbaseRef element as a sub-element.

6) documentation element

� Reading from a file

- Ignores any documentation element that is not a sub-element of an "element" element.

Page 46: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Specifications and Restrictions

40

- Handles a documentation element as a character string concatenated with a text node.When there are several documentation elements, they are all concatenated.

� Writing to a file

- Outputs a single documentation element having a character string as a child.

� Example of reading -> writing[before reading]<element name="..." ...> <annotation> <documentation>This <xhtml:p>is </xhtml:p>a </documentation> <documentation>test.</documentation> </annotation></element>[after writing]<element name="..." ...> <annotation> <documentation>This is a test.</documentation> </annotation></element>

7) import element

� Reading from a file

- Deletes any white spaces before and after the namespace attribute value.

- Deletes any white spaces before and after the schemaLocation attribute value.

- Returns an error if the namespace attribute or schemaLocation is not found.

- Recursively reads the file specified by the import element, and processes it as ataxonomy.

� Writing to a file

- Outputs the namespace attribute value after URI encoding.

- Outputs the schemaLocation attribute value after URI encoding.

8) linkbaseRef element* This element is explained in a subsequent section.

9) Other elements

� Reading from a file

- Ignores any other element.

� Writing to a file

- Does not output any other element.

7.1.2 Linkbase-related elements

1) All linkbase-related elements(Elements belonging to namespace http://www.xbrl.org/2001/XLink/xbrllinkbase)� Reading from a file

Page 47: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Specifications and Restrictions

41

- Abandons namespace prefix information.

- Ignores user-defined attributes.

- Ignores the title element (element having attribute xlink:type="title").

� Writing to a file

- Assigns no namespace prefix (belongs to the default namespace), or assigns prefix xbrll.

2) linkbase element

� Reading from a file

- Abandons schemaLocation attribute information.

� Writing to a file

- Outputs the following namespace declarations:

xmlns="http://www.xbrl.org/2001/XLink/xbrllinkbase"xmlns:xlink="http://www.w3.org/1999/xlink"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:xbrll="http://www.xbrl.org/2001/XLink/xbrllinkbase"

- Adds the following schemaLocation attribute:

xsi:schemaLocation="http://www.xbrl.org/2001/XLink/xbrllinkbase xbrl-linkbase.xsd"

- Outputs sub-elements in sequence from linkbaseRef to an extended link declarationelement.

3) PresentationLink, CalculationLink, DefinitionLink, LabelLink, and ReferenceLink elements

� Reading from a file

- Deletes any white spaces before and after the role attribute value.

� Writing to a file

- Outputs the role attribute value after URI encoding.

4) PresentationArc, CalculationArc, DefinitionArc, LabelArc, and ReferenceArc elements

� Reading from a file

- Deletes any white spaces before and after the arcrole attribute value.

- Deletes any white spaces before and after the use attribute value.

- Deletes any white spaces before and after the priority attribute value.

- Deletes any white spaces before and after the order attribute value. (PresentationArc)

- Deletes any white spaces before and after the weight attribute value. (CalculationArc)

- Requires a parent-to-child arc, and returns an error if it is not found.

- Posts a warning to the error handler if a child-to-parent arc is not found.

- Returns an error if arcrole that is not covered by the XBRL 2.0 Specification is specified.

� Writing to a file

- Outputs the arcrole attribute value after URI encoding.

Page 48: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Specifications and Restrictions

42

5) label element

� Reading from a file

- Deletes any white spaces before and after the label attribute value.

- Deletes any white spaces before and after the role attribute value.

- Deletes any white spaces before and after the lang attribute value.

- Handles a character string that concatenates all low-order text nodes, as a label.

� Writing to a file

- Outputs a label (character string) as a child.

- Outputs the role attribute value after URL encoding.

6) reference element

� Reading from a file

- Deletes any white spaces before and after the label attribute value.

- Deletes any white spaces before and after the role attribute value.

- Deletes any white spaces before and after the lang attribute value.

� Writing to a file

- Adds the namespace declaration of the part element that is a sub-element of the referenceelement, and outputs the namespace URI after URI encoding.

- Outputs the role attribute value after URI encoding.

7) part element

� Reading from a file

- Abandons namespace prefix information.

� Writing to a file

- Assigns a namespace prefix automatically.

---> The prefix is p0, p1, ..., or pn.

- Assigns a namespace declaration automatically to a high-order reference element.

8) loc element

� Reading from a file

- Deletes any white spaces before and after the label attribute value.

- Deletes any white spaces before and after the role attribute value.

- Abandons href attribute value information after link analysis (does not keep Full XPointerand Child Sequence information).

- Posts a warning to the error handler if a calculation link points to something other than anitem.

- Returns an error if the pointing to an "element" element or resource element is notcorrect.

� Writing to a file

- Uses bare name referencing for all href attribute values.

Page 49: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Specifications and Restrictions

43

- Outputs the href attribute value after URI encoding.

- Outputs the role attribute value after URI encoding.

9) linkbaseRef element

* The linkbaseRef element is explained in the next section.

10) Other elements

� Reading from a file

- Ignores any other element.

� Writing to a file

- Does not output any other element.

7.1.3 Instance-related elements

1) All instance-related elements(Elements belonging to namespace http://www.xbrl.org/2001/instance)� Reading from a file

- Abandons namespace prefix information.

- Ignores user-defined attributes.

� Writing to a file

- Assigns no namespace prefix (belongs to the default namespace).

2) group element

� Writing to a file

- Outputs the following namespace declarations:

xmlns="http://www.xbrl.org/2001/instance"xmlns:xbrll="http://www.xbrl.org/2001/XLink/xbrllinkbase"xmlns:xlink="http://www.w3.org/1999/xlink"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:p0="…"xmlns:p1="…"…xmlns:pn="…" (namespace declaration of item or tuple element)

� Writing to a file

- Outputs the schemaLocation attribute value after URI encoding.

- Using a relative path wherever possible, outputs a taxonomy system identifier in theschemaLocation attribute value.

- Outputs sub-elements in sequence from item/tuple tonumericContext/nonNumericContext, linkbaseRef, and then footnoteLink.

3) item and tuple elements

� Reading from a file

Page 50: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Specifications and Restrictions

44

- Abandons namespace prefix information.

- Deletes any white spaces before and after the lang attribute value.

- Deletes any white spaces before and after the numericContext attribute value.

- Deletes any white spaces before and after the nonNumericContext attribute value.

- Makes corrections automatically if an item element uses the nonNumericContext attributeto refer to numeric context or uses the numericContext attribute to refer to nonnumericcontext (posts an error to the error handler).

- Ignores an item element that is not defined in a taxonomy (posts an error to the errorhandler).

- Ignores an item that specifies a nonexistent ID (posts an error to the error handler).

- Ignores an item that does not specify a context ID (posts an error to the error handler).

� Writing to a file

- Assigns a namespace prefix automatically.

-> The prefix is p0, p1, ..., or pn.

- Assigns a namespace declaration automatically to the root group element.

- Assigns the id attribute automatically to the element that is the link destination of afootnote link.

---> The id attribute value is F0, F1, .., or Fn (different from context IDs).

4) linkbaseRef element

� Reading from a file

- Analyzes a linkbaseRef element under nested group elements but its location informationis discarded.

� Writing to a file

- Outputs every linkbaseRef element as a child immediately under the root group element.

* Read also the related description provided below.

5) numericContext and nonNumericContext elements

� Reading from a file

- Deletes any white spaces before and after the id attribute value.

- Deletes any white spaces before and after the precision attribute value. (numericContext)

- Deletes any white spaces before and after the cwa attribute value. (numericContext)

- Discards information on the sequence of sub-elements, but retains information on thesequence of operator sub-elements.

- Recognizes only the first element of sub-elements of the same type that reside as siblings,and discards information about the subsequent elements.

� Writing to a file

- Outputs sub-elements in sequence from entity to period, unit, and then scenario.

6) entity element

� Writing to a file

Page 51: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Specifications and Restrictions

45

- Outputs sub-elements in sequence from identifier to segment.

7) identifier element

� Reading from a file

- Deletes any white spaces before and after the scheme attribute value.

� Writing to a file

- Outputs the scheme attribute value after URI encoding.

8) segment element

� Writing to a file

- Adds the namespace declaration of the segment element to all of its sub-elements.

9) period element

� None

10) period sub-element

� None

11) unit element

� None

12) unit sub-element

� Reading from a file

- Deletes any white spaces before and after the name attribute value in the operatorelement.

13) scenario element

� Writing to a file

- Adds the namespace declaration of the scenario element to all of its sub-elements.

14) footnoteLink element

� Reading from a file

- Abandons namespace prefix information.

- Ignores user-defined attributes.

- Deletes any white spaces before and after the role attribute value.

� Writing to a file

- Assigns the namespace prefix xbrll.

- Outputs the role attribute value after URIencoding.

15) footnoteArc element

� Reading from a file

Page 52: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Specifications and Restrictions

46

- Deletes any white spaces before and after the arcrole attribute value.

- Deletes any white spaces before and after the use attribute value.

- Deletes any white spaces before and after the priority attribute value.

- Requires a parent-to-child arc, and returns an error if it is not found.

- Posts a warning to the error handler if a child-to-parent arc is not found.

- Returns an error if arcrole that is not covered by the XBRL 2.0 Specification is specified.

� Writing to a file

- Outputs the arcrole attribute value after URI encoding.

16) footnote element

� Reading from a file

- Abandons namespace prefix information.

- Ignores user-defined attributes.

- Deletes any white spaces before and after the label attribute value.

- Deletes any white spaces before and after the role attribute value.

- Deletes any white spaces before and after the lang attribute value.

� Writing to a file

- Assigns the namespace prefix xbrll.

- Adds the namespace declaration of the footnote element to all of its sub-elements.

- Outputs the role attribute value after URI encoding.

17) loc element

� Reading from a file

- Abandons namespace prefix information.

- Ignores the user-defined attributes.

- Deletes any white spaces before and after the label attribute value.

- Deletes any white spaces before and after the role attribute value.

- Abandons href attribute value information after link analysis (does not retain FullXPointer and Child Sequence information).

- Returns an error if the pointing to an item element or resource element is not correct.

� Writing to a file

- Assigns the namespace prefix xbrll.

- Uses bare name referencing for all href attribute values.

---> The reference destination is the id attribute value that is automatically assigned to anitem element.

- Outputs the href attribute value after URI encoding.

- Outputs the role attribute value after URI encoding.

18) Other elements

Page 53: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Specifications and Restrictions

47

� Reading from a file

- Ignores any other element.

� Writing to a file

- Does not output any other element.

7.1.4 Common elements

1) LinkbaseRef element

� Reading from a file

- Deletes any white spaces before and after the arcrole attribute value.

- Deletes any white spaces before and after the role attribute value.

- Ignores the actuate and show attributes.

- Ignores low-order nodes.

- Ignores the linkbaseRef elements other than the one that is first analyzed if multiplelinkbaseRef elements (with the same role attribute value) refer to the same linkbase.

- Ignores a reference to a file if the linkbaseRef element written in the file is used for thereference.

- Ignores a role attribute value that is not covered by the XBRL 2.0 Specification (posts anerror to the error handler).

� Writing to a file

- Outputs linkbaseRef elements in sequence from the presentation link to the calculationlink, definition link, label link, and then reference link.

- Outputs the character string presentationLink, calculationLink, definitionLink, labelLink,or referenceLink as a child depending on the link type.

- Outputs only the linkbaseRef element that is first analyzed if multiple linkbaseRefelements refer to the same linkbase.

- Assigns the namespace prefix xbrll.

- Outputs the href attribute value after URI encoding.

- Outputs the role attribute value after URI encoding.

7.2 Other specifications� The nonNumericContext, numericContext, linkbaseRef, and footnoteLink elements under

nested group elements are moved to a location immediately under the root group elementduring output.

� When a label, reference, or footnote is written as a remote resource, the child element of theelement indicated by the locator is set as a resource (the element indicated by the locator is notset as a resource). If the element indicated by the locator has the lang attribute, the childelement is set as the language. It is added as a resource element (having xlink:type="resource"as an attribute) in linkbase (becomes a local resource) during output.

� Overriding of label links applies to a link having the same resource language and roleattributes.

� Overriding of references or footnote links applies to a link having the same resource language.

Page 54: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Specifications and Restrictions

48

� A presentation link, calculation link, definition link, label link, or reference link must bewritten in a linkbase document.

� A footnote link must be written in an instance document.

� A precision attribute value is handled as a significant number. Calculations based on acalculation link are made according to the significant number.

� If two or more taxonomies having the same targetNamespace attribute value are read, alltaxonomies except the one that is first analyzed are ignored.

� A DOM constructed with parsers that do not recognize a namespace cannot be handled.

� An error occurs if a loop exists in a relation link.

� The maximum number of objects that can be added with add-method or insert-method isInteger.MAX_VALUE. If the number exceeds the maximum value, added objects areignored.

� A value normalized to represent white space must be specified in the following methods usedto check the validity of the specified value in an XBRL model. An error results if a whitespace string is inserted before or after the value.

o DocumentInformation.setSystemId(String sysId)

o XBRLLocator.setRole(String role)

o XBRLLocator.setLabel(String label)

o XBRLXLinkDecl.setRole(String role)

o Item.setType(String namespaceURI, String localName)

o XBRLElement.setName(String name)

o XBRLElement.setId(String id)

o Context.setId(String id)

o Footnote.setLanguage(String lang)

o NonNumericValue.setLanguage(String lang)

o XBRLEntity.setScheme(String scheme)

o Label.setLanguage(String lang)

o Part.setNamespaceURI(String namespaceURI)

o Part.setLocalName(String localName)

o Reference.setLanguage(String lang)

o SchemaImport.setNamespace(String namespace)

o SchemaImport.setSchemaLocation(String sLocation)

o TaxonomyInformation.setTargetNamespace(String namespace)

� Multiple kinds of links cannot be written in a linkbase file.

7.3 Restrictions� The schemes supported as system identifiers are file, http, https, and ftp.

� Only normalized system identifiers can be specified. Operation is not assured if a systemidentifier that has not been normalized is specified.Example:Acceptable: http://www.foo.com/cUnacceptable: http://www.foo.com/d/../c

Page 55: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Specifications and Restrictions

49

� Some methods which check the validity of the specified value in an XBRL data model supportonly a partial check and do not perform a complete check

Restricted methods are as follows. Meanings of the brevity codes, which are used in thefollowing table, are described later.

Methods RestrictionsDocumentInformation.setSystemId(String sysId) sysId: RSIDXBRLLocator.setRole(String role) role: RURIXBRLLocator.setLabel(String label) label: RNCNXBRLXLinkDecl.setRole(String role) role: RURIItem.setType(String nsURI, String lName) nsURI: RURI, lName: RNCN

If Item.XBRL_INSTANCE_NS_URI is setto the “nsURI” and a constant in the Itemclass is set to the “lName”, a validationcheck of the specified value is performed.But there are following restrictions.lNameRestrictions

TYPE_MONETARY_ITEMRDEC

TYPE_SHARES_ITEMRDEC

TYPE_DECIMAL_ITEMRDEC

TYPE_URI_ITEMRURI

TYPE_DATE_TIME_ITEMNONE

OtherElement.setSubstitutionGroup(String nsURI,String lName)

nsURI: RURI, lName: RNCN

Tuple.setType(String nsURI, String lName) nsURI: RURI, lName: RNCNXBRLElement.setType(String nsURI, String lName) nsURI: RURI, lName: RNCNXBRLElement.setId(String id) id: RNCNXBRLElement.setName(String name) name: RNCNContext.setId(String id) id: RNCNDEPeriod.setDuration(String duration) duration: NONEDEPeriod.setEndDate(String date) date: NONEFootnote.setLanguage(String lang) lang: RLNGInstant.setDate(String date) date: NONEMeasure.setValue(String value) value: RQNANonNumericValue.setLanguage(String lang) lang: RLNGSDPeriod.setDuration(String duration) duration: NONESDPeriod.setStartDate(String date) date: NONESEPeriod.setEndDate(String date) date: NONESEPeriod.setStartDate(String date) date: NONEValue.setSpecified(String specified) If Item.XBRL_INSTANCE_NS_URI is set

as a namespace URI and a constant in theItem class is set as a local name in the typeattribute of the item to which the value

Page 56: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Specifications and Restrictions

50

belongs, a validation check of the“specified” is performed. But there arefollowing restrictions.Local namesRestrictions

TYPE_MONETARY_ITEMRDEC

TYPE_SHARES_ITEMRDEC

TYPE_DECIMAL_ITEMRDEC

TYPE_URI_ITEMRURI

TYPE_DATE_TIME_ITEMNONE

XBRLEntity.setScheme(String scheme) scheme: RURILabel.setLanguage(String lang) lang: RLNGPart.setLocalName(String lName) lName: RNCNPart.setNamespaceURI(String nsURI) usURI: RURIReference.setLanguage(String lang) lang: RLNGSchemaImport.setNamespace(String nsURI) usURI: RURISchemaImport.setSchemaLocation(String location) location: RURITaxonomyInformation.setTargetNamespace(StringnsURI)

usURI: RURI

Meanings (exception conditions) of the brevity codes are as follows.Brevity codes Meanings (exception conditions)NONE validation checks are not performed.RDEC - A string is not a floating-point numberRSID - A string is empty

- A string contains white spaces before or after it- A protocol of an URL string is unknown- A file path cannot be translated to an URL

RURI - A string contains white spaces before or after itRLNG - A string is empty

- A string contains white spacesRNCN - A string is empty

- A string contains white spaces- A string contains ':'- A string starts with a number- A string starts with '.'- A string starts with '-'

RQNA - A string is empty- A string contains ':' before or after it- A string contains two or more ':'- A prefix or a local name is not valid as NCName

.

Page 57: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Pseudo XPath

51

Appendix A Pseudo XPathThe value of an item in an XBRL data model is registered using the context to which the valuebelongs and an XPath location-path-like character string. For example:<group xmlns="http://www.xbrl.org/2001/instance" xmlns:t="http://www.hoge.com/"> <t:tuple1> <t:tuple2> <t:item numericContext="C0">100</item> </t:tuple2> </t:tuple1> </group>

Register this item using context "C0" and the following location-path-like character string: /{http://www.xbrl.org/2001/instance}:group[1] /{http://www.hoge.com/}:tuple1[1] /{http://www.hoge.com/}:tuple2[1]This location-path-like character string is referred to as pseudo XPath. Note that pseudo XPathdoes not include the path of the item to be registered.

Pseudo XPath is based on XPath1.0 except for the following differences:

� No axes can be specified. Only child axes are supported.(Child axes are usually omitted in statements.)

� A namespace URI enclosed by curly braces {} must be used for a node test instead of anamespace prefix.

� Only one predicate must always be specified.

� Only a numeric value can be specified as an expression in the predicate.

� No white spaces can be included in pseudo XPath statements.

Coding procedure:

1) Write the absolute path (from the root node) of the location path without an expression in thepredicate. To do so, simply extract elements from the instance document, and place them onthe line. Always omit axes. /group/t:tuple1/t:tuple2

2) Specify predicates according to the condition of the instance document. Add [number] to eachelement. /group[1]/t:tuple1[1]/t:tuple2[1]

3) Re-assign the namespace prefix to the namespace (do the same even with the defaultnamespace prefix).Perform URI encoding if necessary.

/{http://www.xbrl.org/2001/instance}:group[1] /{http://www.hoge.com/}:tuple1[1] /{http://www.hoge.com/}:tuple2[1]

Because XBRL namespace http://www.xbrl.org/2001/instance is defined in Item.XBRL_INSTANCE_NS_URI, it can be used from within programs.

Page 58: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Tutorial Source Programs

52

Appendix B Tutorial Source Programs--- XBRLSample.java ---

import java.io.*;import com.fujitsu.xml.xbrl.processor.*;import com.fujitsu.xml.xbrl.datamodel.instance.*;import com.fujitsu.xml.xbrl.datamodel.taxonomy.*;import com.fujitsu.xml.xbrl.datamodel.common.*;import com.fujitsu.xml.xbrl.datamodel.core.*;

class XBRLSample { public static void main(String args[]) { XBRLProcessor xbrlProc = new XBRLProcessor(); XBRLDocument xbrlDoc = xbrlProc.createNewDocument(); String taxSysId = "sampleTaxonomy.xsd"; String insSysId = "sampleInstance.xml";

// Create and specify taxonomy information. TaxonomyInformation taxInfo = xbrlDoc.createTaxonomyInformation(); taxInfo.setSystemId(taxSysId); taxInfo.setTargetNamespace("http://foo.nowhere/namespace/target"); xbrlDoc.addTaxonomyInformation(taxInfo);

// Create and specify instance information. InstanceInformation insInfo = xbrlDoc.createInstanceInformation(); insInfo.setSystemId(insSysId); xbrlDoc.setInstanceInformation(insInfo);

// Add item elements. Item item = (Item)xbrlDoc.createElement(taxInfo, XBRLElement.ELEMENT_TYPE_ITEM); item.setId("sample_id"); item.setName("sample_name"); item.setType(Item.XBRL_INSTANCE_NS_URI, Item.TYPE_MONETARY_ITEM); xbrlDoc.addElement(item);

Item item2 = (Item)xbrlDoc.createElement(taxInfo, XBRLElement.ELEMENT_TYPE_ITEM); item2.setId("sample_id2"); item2.setName("sample_name2"); item2.setType(Item.XBRL_INSTANCE_NS_URI, Item.TYPE_MONETARY_ITEM); xbrlDoc.addElement(item2);

// Add values. Context context = xbrlDoc.createContext(insInfo, Context.CONTEXT_TYPE_NUMERIC); context.setId("i1"); XBRLEntity entity = context.createEntity(); entity.setIdentifier("SAMPLE"); entity.setScheme("sample.nowhere"); context.setEntity(entity); Instant instant = (Instant)context.createPeriod( Period.PERIOD_TYPE_INSTANT);

instant.setDate("2001-12-14"); context.setPeriod(instant); Measure measure = (Measure)context.createUnit(Unit.UNIT_TYPE_MEASURE); measure.setValue("ISO4217:JPY"); context.setUnit(measure); xbrlDoc.addContext(context);

String xpath = "/{" + Item.XBRL_INSTANCE_NS_URI+ "}:group[1]";

Value value = item.createValue(Value.VALUE_TYPE_NUMERIC); value.setSpecified("100"); item.addValue(context, xpath, value);

Page 59: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Tutorial Source Programs

53

// Add a link. // Register a presentation link reference. LinkbaseInformation lbInfo = taxInfo.createLinkbaseInformation(); lbInfo.setSystemId("link_presentaion.xml"); taxInfo.addPresentationLinkbaseInformation(lbInfo); // Create link data. PresentationLinkData pLink = (PresentationLinkData)xbrlDoc.createLinkData( LinkData.LINK_DATA_TYPE_PRESENTATION); // Specify an element in a link node. pLink.setElement(item); // Register link data as the root. xbrlDoc.addRootPresentationLinkData(pLink);

// Create link data containing an element for which a link is to be registered. PresentationLinkData childLink = (PresentationLinkData) xbrlDoc.createLinkData( LinkData.LINK_DATA_TYPE_PRESENTATION); childLink.setElement(item2);

pLink.addChild(childLink); XBRLXLinkDecl xDecl = taxInfo.getPresentationLinkbaseInformation(0).createXLinkDecl(); PresentationArc arc =(PresentationArc)xDecl.createArc(XBRLArc.ARC_TYPE_PRESENTATION); arc.setArcRole(RelationArc.ARC_ROLE_PARENT_CHILD); PresentationArc cArc =(PresentationArc)xDecl.createArc(XBRLArc.ARC_TYPE_PRESENTATION); cArc.setArcRole(RelationArc.ARC_ROLE_CHILD_PARENT); arc.setOrder(10); cArc.setOrder(10);

XBRLLocator srcLoc = xDecl.createLocator(); if (xbrlDoc.containsRootPresentationLinkData(pLink)){ srcLoc.setRole(XBRLLocator.ROLE_ROOT); } srcLoc.setLabel("src"); XBRLLocator destLoc = xDecl.createLocator(); destLoc.setLabel("dest"); LinkInformation linkInformation =pLink.createLinkInformation(arc, cArc, srcLoc, destLoc); pLink.addLinkInformation(childLink, linkInformation);

// Define a label link reference. LinkbaseInformation lbInfo2 = taxInfo.createLinkbaseInformation(); lbInfo2.setSystemId("link_label.xml"); taxInfo.addLabelLinkbaseInformation(lbInfo2);

LabelLinkData lLink = (LabelLinkData)xbrlDoc.createLinkData(LinkData.LINK_DATA_TYPE_LABEL); xbrlDoc.setLabelLinkData(lLink);

// Create a label resource. Label label = lLink.createLabel(); label.setLanguage("ja"); label.setValue("Test");

// Define the link destination resource in link data. lLink.addLabel(item, label);

// Create link information. xDecl = taxInfo.getLabelLinkbaseInformation(0).createXLinkDecl(); LabelArc arc2 = (LabelArc)xDecl.createArc(XBRLArc.ARC_TYPE_LABEL); arc2.setArcRole(LabelArc.ARC_ROLE_ELEMENT_LABEL); LabelArc cArc2 = (LabelArc)xDecl.createArc(XBRLArc.ARC_TYPE_LABEL); cArc2.setArcRole(LabelArc.ARC_ROLE_LABEL_ELEMENT); srcLoc = xDecl.createLocator(); srcLoc.setLabel("element"); destLoc = xDecl.createLocator();

Page 60: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Tutorial Source Programs

54

destLoc.setLabel("label");

linkInformation = lLink.createLinkInformation(arc2, cArc2, srcLoc, destLoc);

// Define link information. lLink.setLinkInformation(item, label, linkInformation);

// Save taxonomies, linkbases, and instance documents. try { xbrlProc.saveTaxonomy(xbrlDoc, taxInfo, null); xbrlProc.saveTaxonomy(xbrlDoc, lbInfo, null); xbrlProc.saveTaxonomy(xbrlDoc, lbInfo2, null); xbrlProc.saveInstance(xbrlDoc, null); } catch (java.io.IOException e) { System.out.println("save error."); } catch (org.xml.sax.SAXException e) { System.out.println("save error."); } catch (javax.xml.transform.TransformerException e) { System.out.println("save error."); } catch (XBRLProcessorException e) { System.out.println("save error."); }

// Serialize the XBRL document data model. try { FileOutputStream outputStream = new FileOutputStream("serialize.dat"); xbrlProc.serializeDocument(xbrlDoc, outputStream); } catch (Exception e) { System.out.println("Serialize error."); } }}

Execution results

--- Taxonomy: sampleTaxonomy.xsd

<?xml version="1.0" encoding="UTF-8"?><schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:xbrli="http://www.xbrl.org/2001/instance" xmlns:xbrll="http://www.xbrl.org/2001/XLink/xbrllinkbase" xmlns:xlink="http://www.w3.org/1999/xlink" targetNamespace="http://foo.nowhere/namespace/target"> <annotation> <appinfo> <xbrll:linkbaseRef xlink:type="simple" xlink:actuate="onRequest" xlink:arcrole="http://www.w3.org/1999/xlink/properties/linkbase" xlink:href="link_presentaion.xml" xlink:role="http://www.xbrl.org/linkprops/linkRef/presentation"> presentationLink </xbrll:linkbaseRef> <xbrll:linkbaseRef xlink:type="simple" xlink:actuate="onRequest" xlink:arcrole="http://www.w3.org/1999/xlink/properties/linkbase" xlink:href="link_label.xml" xlink:role="http://www.xbrl.org/linkprops/linkRef/label"> labelLink </xbrll:linkbaseRef> </appinfo> </annotation> <element id="sample_id" name="sample_name" type="xbrli:monetaryItemType" substitutionGroup="xbrli:item"/> <element id="sample_id2" name="sample_name2" type="xbrli:monetaryItemType" substitutionGroup="xbrli:item"/></schema>

Page 61: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Tutorial Source Programs

55

--- Linkbase document: link_presentaion.xml ---

<?xml version="1.0" encoding="UTF-8"?><linkbase xmlns="http://www.xbrl.org/2001/XLink/xbrllinkbase" xmlns:xbrll="http://www.xbrl.org/2001/XLink/xbrllinkbase" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.xbrl.org/2001/XLink/xbrllinkbase xbrl-linkbase.xsd"> <presentationLink xlink:type="extended"> <loc xlink:type="locator" xlink:href="sampleTaxonomy.xsd#sample_id" xlink:label="src" xlink:role="http://www.xbrl.org/linkprops/locator/root"/> <loc xlink:type="locator" xlink:href="sampleTaxonomy.xsd#sample_id2" xlink:label="dest"/> <presentationArc xlink:type="arc" xlink:arcrole="http://www.xbrl.org/linkprops/arc/parent-child" xlink:from="src" xlink:to="dest" xlink:actuate="onRequest" xlink:show="replace" priority="0" order="10.0"/> <presentationArc xlink:type="arc" xlink:arcrole="http://www.xbrl.org/linkprops/arc/child-parent" xlink:from="dest" xlink:to="src" xlink:actuate="onRequest" xlink:show="replace" priority="0" order="10.0"/> </presentationLink></linkbase>

--- Linkbase document: link_label.xml ---

<?xml version="1.0" encoding="UTF-8"?><linkbase xmlns="http://www.xbrl.org/2001/XLink/xbrllinkbase" xmlns:xbrll="http://www.xbrl.org/2001/XLink/xbrllinkbase" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.xbrl.org/2001/XLink/xbrllinkbase xbrl-linkbase.xsd"/> <labelLink xlink:type="extended"> <loc xlink:type="locator" xlink:href="sampleTaxonomy.xsd#sample_id" xlink:label="element"/> <label xlink:type="resource" xlink:label="label" xml:lang="ja">Test</label> <labelArc xlink:type="arc" xlink:arcrole="http://www.xbrl.org/linkprops/arc/element-label" xlink:from="element" xlink:to="label" xlink:actuate="onRequest" xlink:show="embed" priority="0"/> <labelArc xlink:type="arc" xlink:arcrole="http://www.xbrl.org/linkprops/arc/label-element" xlink:from="label" xlink:to="element" xlink:actuate="onRequest" xlink:show="replace" priority="0"/> </labelLink></linkbase>

--- Instance document: sampleInstance.xml ---

<?xml version="1.0" encoding="UTF-8"?><group xmlns="http://www.xbrl.org/2001/instance" xmlns:p0="http://foo.nowhere/namespace/target" xmlns:xbrll="http://www.xbrl.org/2001/XLink/xbrllinkbase" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://foo.nowhere/namespace/target sampleTaxonomy.xsd"> <p0:sample_name numericContext="i1">100</p0:sample_name> <numericContext cwa="false" id="i1" precision="1"> <entity> <identifier scheme="sample.nowhere">SAMPLE</identifier> </entity> <period> <instant>2001-12-14</instant> </period>

Page 62: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Tutorial Source Programs

56

<unit> <measure>ISO4217:JPY</measure> </unit> </numericContext></group>

- Serialize file: serialize.dat --- * This file is not provided here because it is a binary file.

Page 63: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Samples of Overridden Documents

57

Appendix C Samples of Overridden Documents--- Taxonomy: sample_base.xsd ---

<?xml version="1.0" encoding="UTF-8"?><schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:xbrli="http://www.xbrl.org/2001/instance" xmlns:xbrll="http://www.xbrl.org/2001/XLink/xbrllinkbase" xmlns:xlink="http://www.w3.org/1999/xlink" targetNamespace="http://www.fujitsu.com/demo/2002-11-11"> <annotation> <appinfo> <xbrll:linkbaseRef xlink:type="simple" xlink:actuate="onRequest" xlink:arcrole="http://www.w3.org/1999/xlink/properties/linkbase" xlink:href="link_base.xml" xlink:role="http://www.xbrl.org/linkprops/linkRef/presentation"> presentationLink </xbrll:linkbaseRef> </appinfo> </annotation> <element id="testroot" name="testroot" type="xbrli:monetaryItemType" substitutionGroup="xbrli:item"/> <element id="test1" name="test1" type="xbrli:monetaryItemType" substitutionGroup="xbrli:item"/> <element id="test2" name="test2" type="xbrli:monetaryItemType" substitutionGroup="xbrli:item"/></schema>

--- Taxonomy: sample_over.xsd ---<?xml version="1.0" encoding="UTF-8"?><schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:xbrli="http://www.xbrl.org/2001/instance" xmlns:xbrll="http://www.xbrl.org/2001/XLink/xbrllinkbase" xmlns:xlink="http://www.w3.org/1999/xlink" targetNamespace="http://www.fujitsu.com/demo/2002-11-12"> <annotation> <appinfo> <xbrll:linkbaseRef xlink:type="simple" xlink:actuate="onRequest" xlink:arcrole="http://www.w3.org/1999/xlink/properties/linkbase" xlink:href="link_over.xml" xlink:role="http://www.xbrl.org/linkprops/linkRef/presentation"> presentationLink </xbrll:linkbaseRef> </appinfo> </annotation> <import namespace="http://www.fujitsu.com/demo/2002-11-11" schemaLocation="sample_base.xsd"/></schema>

--- Link document: link_base.xml ---<?xml version="1.0" encoding="UTF-8"?><linkbase xmlns="http://www.xbrl.org/2001/XLink/xbrllinkbase" xmlns:xbrll="http://www.xbrl.org/2001/XLink/xbrllinkbase" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.xbrl.org/2001/XLink/xbrllinkbase xbrl-linkbase.xsd"> <presentationLink xlink:type="extended"> <loc xlink:type="locator" xlink:href="sample_base.xsd#testroot" xlink:label="src" xlink:role="http://www.xbrl.org/linkprops/locator/root"/> <loc xlink:type="locator" xlink:href="sample_base.xsd#test1" xlink:label="dest"/> <presentationArc xlink:type="arc"

Page 64: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Samples of Overridden Documents

58

xlink:arcrole="http://www.xbrl.org/linkprops/arc/parent-child" xlink:from="src" xlink:to="dest" xlink:actuate="onRequest" xlink:show="replace" priority="0" order="1.0"/> <presentationArc xlink:type="arc" xlink:arcrole="http://www.xbrl.org/linkprops/arc/child-parent" xlink:from="dest" xlink:to="src" xlink:actuate="onRequest" xlink:show="replace" priority="0" order="1.0"/> </presentationLink> <presentationLink xlink:type="extended"> <loc xlink:type="locator" xlink:href="sample_base.xsd#testroot" xlink:label="src" xlink:role="http://www.xbrl.org/linkprops/locator/root"/> <loc xlink:type="locator" xlink:href="sample_base.xsd#test2" xlink:label="dest"/> <presentationArc xlink:type="arc" xlink:arcrole="http://www.xbrl.org/linkprops/arc/parent-child" xlink:from="src" xlink:to="dest" xlink:actuate="onRequest" xlink:show="replace" priority="0" order="1.0"/> <presentationArc xlink:type="arc" xlink:arcrole="http://www.xbrl.org/linkprops/arc/child-parent" xlink:from="dest" xlink:to="src" xlink:actuate="onRequest" xlink:show="replace" priority="0" order="1.0"/> </presentationLink></linkbase>

--- Link document: link_over.xml ---<?xml version="1.0" encoding="UTF-8"?><linkbase xmlns="http://www.xbrl.org/2001/XLink/xbrllinkbase" xmlns:xbrll="http://www.xbrl.org/2001/XLink/xbrllinkbase" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.xbrl.org/2001/XLink/xbrllinkbase xbrl-linkbase.xsd"> <presentationLink xlink:type="extended"> <loc xlink:type="locator" xlink:href="sample_base.xsd#testroot" xlink:label="src" xlink:role="http://www.xbrl.org/linkprops/locator/root"/> <loc xlink:type="locator" xlink:href="sample_base.xsd#test2" xlink:label="dest"/> <presentationArc xlink:type="arc" xlink:arcrole="http://www.xbrl.org/linkprops/arc/parent-child" xlink:from="src" xlink:to="dest" xlink:actuate="onRequest" xlink:show="replace" priority="1" order="0.1"/> <presentationArc xlink:type="arc" xlink:arcrole="http://www.xbrl.org/linkprops/arc/child-parent" xlink:from="dest" xlink:to="src" xlink:actuate="onRequest" xlink:show="replace" priority="1" order="0.1"/> </presentationLink></linkbase>

--- OverrideSample.java ---import java.io.*;import com.fujitsu.xml.xbrl.processor.*;import com.fujitsu.xml.xbrl.datamodel.instance.*;import com.fujitsu.xml.xbrl.datamodel.taxonomy.*;import com.fujitsu.xml.xbrl.datamodel.common.*;import com.fujitsu.xml.xbrl.datamodel.core.*;import javax.xml.transform.stream.*;

class OverrideSample {

public static void main(String args[])throws Exception { XBRLProcessor xbrlProc = new XBRLProcessor(); // Document before overriding XBRLDocument xbrlDoc = xbrlProc.loadTaxonomy(new StreamSource(new File("sample_base.xsd"))); System.err.println("===== Before overriding =====");

Page 65: Interstage XWand XBRL Processor Development Guide · The manual provides an outline of an XBRL processor, and it describes functions supported by the XBRL processor and how to use

Samples of Overridden Documents

59

test(xbrlDoc.getRootPresentationLinkData(0));

System.err.println();

// Document after overriding xbrlDoc = xbrlProc.loadTaxonomy(new StreamSource(new File("sample_over.xsd"))); System.err.println("===== After overriding ====="); test(xbrlDoc.getRootPresentationLinkData(0)); }

public static void test(PresentationLinkData presentation){ java.util.Enumeration enum = presentation.getOrderedChildren(); while(enum.hasMoreElements()){ PresentationLinkData pLinkData = (PresentationLinkData)enum.nextElement(); System.err.println(pLinkData.getElement().getName()); } }}

--- Output on console ---===== Before overriding =====test1test2(omitted)===== After overriding =====test2test1