© 2006 XBRL International, All Rights Reserved www.xbrl.org/Legal Ignacio Hernández-Ros Technology development XBRL International Using XQuery to process XBRL
Dec 31, 2015
© 2006 XBRL International, All Rights Reserved www.xbrl.org/Legal
Ignacio Hernández-RosTechnology development
XBRL International
Using XQuery to process XBRL
Haga clic para cambiar el estilo de título
Haga clic para modificar el estilo de subtítulo del patrón
© 2006 XBRL International, All Rights Reserved www.xbrl.org/Legal
Using XQuery to process XBRL
1. What’s XQuery?
2. What’s the relationship between XBRL and XQuery?
3. Using the XBRL functions library
8’
10’
8’
Haga clic para cambiar el estilo de título
Haga clic para modificar el estilo de subtítulo del patrón
© 2006 XBRL International, All Rights Reserved www.xbrl.org/Legal
What’s XQuery
• XQuery is a W3C standard• http://www.w3.org/TR/xquery/• The status is Candidate Release 3 Nov.
2005• XQuery is an extension of XPath 2.0• Defines semantics about processing XML
information• Is not related to any database or storage
system
Haga clic para cambiar el estilo de título
Haga clic para modificar el estilo de subtítulo del patrón
© 2006 XBRL International, All Rights Reserved www.xbrl.org/Legal
What’s XQuery
• But … the most important thing is how XQuery gives you productivity
Dev
elop
men
t ef
fort
C/C++ Java/.net XQuery
Notes:1. XQuery is not so powerful
as the other programming languages.
2. XQuery execution performance is comparable with scripts over compiled programming languages.
3. XQuery development requires deep XML knowledge and related technologies like XPath 2.0
Haga clic para cambiar el estilo de título
Haga clic para modificar el estilo de subtítulo del patrón
© 2006 XBRL International, All Rights Reserved www.xbrl.org/Legal
What’s XQuery
• Comparing XQuery with XPath 2.0– Both have more things in common than
differences.– A way to do the research is to look at the
differences in the processing model of both languages.
Haga clic para cambiar el estilo de título
Haga clic para modificar el estilo de subtítulo del patrón
© 2006 XBRL International, All Rights Reserved www.xbrl.org/Legal
What is XQuery
• XQuery over XPath 2.0 Find the 3 differences
XQ
uer
y XP
ath
2.0
Haga clic para cambiar el estilo de título
Haga clic para modificar el estilo de subtítulo del patrón
© 2006 XBRL International, All Rights Reserved www.xbrl.org/Legal
What is XQuery
• 3 – XQuery query prolog supports parameterization of the execution engine
XQ
uer
y XP
ath
2.0
Haga clic para cambiar el estilo de título
Haga clic para modificar el estilo de subtítulo del patrón
© 2006 XBRL International, All Rights Reserved www.xbrl.org/Legal
What is XQuery
• 1 – XQuery supports modules and modules contains functions– Functions encapsulate the XQuery complexity from the business side– Modules may be stored in web servers
XQ
uer
y XP
ath
2.0
Haga clic para cambiar el estilo de título
Haga clic para modificar el estilo de subtítulo del patrón
© 2006 XBRL International, All Rights Reserved www.xbrl.org/Legal
What is XQuery
• 2 – XQuery supports XML Schema type checking and validation
XQ
uer
y XP
ath
2.0
Haga clic para cambiar el estilo de título
Haga clic para modificar el estilo de subtítulo del patrón
© 2006 XBRL International, All Rights Reserved www.xbrl.org/Legal
What is XQuery
• So, XQuery supports:– modules and – strong XML schema validation.– Plus a uniform platform to access/execute the
code.
• These two characteristics make XQuery a powerful language to process XML/XBRL infosets.
Haga clic para cambiar el estilo de título
Haga clic para modificar el estilo de subtítulo del patrón
© 2006 XBRL International, All Rights Reserved www.xbrl.org/Legal
What’s the relationship between XBRL and XQuery?
• Is there any relationship?– NOT YET
• If there were relationships, what might they be?– The Formula linkbase already uses XPath 2.0– XPath 2.0 can use functions defined in
XQuery modules– A linkbase may declare the XQuery modules
where the required functions are defined
Haga clic para cambiar el estilo de título
Haga clic para modificar el estilo de subtítulo del patrón
© 2006 XBRL International, All Rights Reserved www.xbrl.org/Legal
What’s the relationship between XBRL and XQuery?
XBRLTaxonomy
Labels lb
Presentation lb
Calculation lb
Reference lb
Definition lb
Haga clic para cambiar el estilo de título
Haga clic para modificar el estilo de subtítulo del patrón
© 2006 XBRL International, All Rights Reserved www.xbrl.org/Legal
What’s the relationship between XBRL and XQuery?
XBRLTaxonomy
Labels lb
Presentation lb
Calculation lb
Reference lb
Definition lb
Formula lb
Haga clic para cambiar el estilo de título
Haga clic para modificar el estilo de subtítulo del patrón
© 2006 XBRL International, All Rights Reserved www.xbrl.org/Legal
What’s the relationship between XBRL and XQuery?
XBRLTaxonomy
Labels lb
Presentation lb
Calculation lb
Reference lb
Definition lb
Formula lbFunctionsmoduleFunctionsmoduleFunctionsmodules
Haga clic para cambiar el estilo de título
Haga clic para modificar el estilo de subtítulo del patrón
© 2006 XBRL International, All Rights Reserved www.xbrl.org/Legal
What’s the relationship between XBRL and XQuery?
Formula lbFunctionsmoduleFunctionsmoduleFunctionsmodules
Should contain:• Locators to taxonomy concepts• Resources of multiple types
• References to modules• Constants definitions• Variable definitions• Business side of the formula
• Arcs• Linking all together
Should contain:• Other modules• Other XML Schemas• IT side of the formula
This is, the real formula implementation for any XBRL element regardless of the taxonomy in use
Haga clic para cambiar el estilo de título
Haga clic para modificar el estilo de subtítulo del patrón
© 2006 XBRL International, All Rights Reserved www.xbrl.org/Legal
What’s the relationship between XBRL and XQuery?
Formula lbFunctionsmoduleFunctionsmoduleFunctionsmodules
Example(*): Example(*):<formulaLink xlink:type="extended" xlink:role="http://www.xbrl.org/2003/role/link">
<module xlink:type="resource" namespace="http://xbrl.org/2006/functions" uri="http://www.xbrl.org/2006/functions/xf-2006.xq" prefix="xfi"/>
<link:locVariable xlink:type="locator" xlink:label="item1" xlink:href="TaxonomySchema.xsd#Cash" name="Cash"/>
<link:locVariable xlink:type="locator" xlink:label="item2" xlink:href="TaxonomySchema.xsd#IncreaseDecreaseInCash" name="ChangesInCash"/>
<formula xlink:type="resource" xlink:label="movementAnalisys" select="xfi:CheckMovement($Cash,$ChangesInCash,P3M)"/>
</formulaLink>
xquery version “1.0”;module namespace xfi = “http://xbrl.org/2006/functions”;
import schema namespace xl = "http://www.xbrl.org/2003/XLink" at "http://www.xbrl.org/2003/xl-2003-12-31.xsd";
declare function xfi:CheckMovement($instantVar as schema-element(xbrli:item),$durationVar as schema-element(xbrli:item), $period as xdt:yearMonthDuration) as boolean{
if (…) thentrue()
elsefalse()
};
(*) Examples do not represent the syntax of the XII formula linkbase (under development)
Haga clic para cambiar el estilo de título
Haga clic para modificar el estilo de subtítulo del patrón
© 2006 XBRL International, All Rights Reserved www.xbrl.org/Legal
What’s the relationship between XBRL and XQuery?
Formula lbFunctionsmoduleFunctionsmoduleFunctionsmodules
Example(*): Example(*):<formulaLink xlink:type="extended" xlink:role="http://www.xbrl.org/2003/role/link">
<module xlink:type="resource" namespace="http://xbrl.org/2006/functions" uri="http://www.xbrl.org/2006/functions/xf-2006.xq" prefix="xfi"/>
<link:locVariable xlink:type="locator" xlink:label="item1" xlink:href="TaxonomySchema.xsd#Cash" name="Cash"/>
<link:locVariable xlink:type="locator" xlink:label="item2" xlink:href="TaxonomySchema.xsd#IncreaseDecreaseInCash" name="ChangesInCash"/>
<formula xlink:type="resource" xlink:label="movementAnalisys" select="xfi:CheckMovement($Cash,$ChangesInCash,P3M)"/>
</formulaLink>
xquery version “1.0”;module namespace xfi = “http://xbrl.org/2006/functions”;
import schema namespace xl = "http://www.xbrl.org/2003/XLink" at "http://www.xbrl.org/2003/xl-2003-12-31.xsd";
declare function xfi:CheckMovement($instantVar as schema-element(xbrli:item),$durationVar as schema-element(xbrli:item), $period as xdt:yearMonthDuration) as boolean{
if (…) thentrue()
elsefalse()
};
(*) Examples do not represent the syntax of the XII formula linkbase (under development)
Formula processors would be free to use the XQuery version of the function or a
local (faster) version
Haga clic para cambiar el estilo de título
Haga clic para modificar el estilo de subtítulo del patrón
© 2006 XBRL International, All Rights Reserved www.xbrl.org/Legal
What’s the relationship between XBRL and XQuery?
• Tools will hide the complexity of the formula linkbase in the business side.
• Functions should be developed by people that:– Understand XBRL– Understand XQuery– Some might be written by the XII Spec WG
• Functions are reusable material between taxonomies
Haga clic para cambiar el estilo de título
Haga clic para modificar el estilo de subtítulo del patrón
© 2006 XBRL International, All Rights Reserved www.xbrl.org/Legal
Using the XBRL functions library
• During the development of the formula/functions XBRL specification, a set of functions to work with XBRL has been defined (IWD of the spec WG)
• Those functions will be part of the final XBRL functions specification
• All of those functions are now implemented in an XQuery module (xfi) “xf-2006.xq” as a “Proof of Concept”
Haga clic para cambiar el estilo de título
Haga clic para modificar el estilo de subtítulo del patrón
© 2006 XBRL International, All Rights Reserved www.xbrl.org/Legal
Using the XBRL functions library
• That XQuery module can be used to– Learn XQuery and how XQuery can process
XBRL– Develop higher level functions
• For testing instance document content• For transforming instance documents• For providing feedback to the Spec WG• …
Haga clic para cambiar el estilo de título
Haga clic para modificar el estilo de subtítulo del patrón
© 2006 XBRL International, All Rights Reserved www.xbrl.org/Legal
Using the XBRL functions library
• Yes but how can I do that?– You need:
• An XQuery processor (e.g., Altova XML Spy, Saxon, …)• A sample instance document• XQuery code written by you
XBRL Instance
XQueryprocessor
YourXQuery
XII XQuery Module
OutputXML
Haga clic para cambiar el estilo de título
Haga clic para modificar el estilo de subtítulo del patrón
© 2006 XBRL International, All Rights Reserved www.xbrl.org/Legal
Using the XBRL functions library
• Function blocks:– Accessor functions: provide access to content
in the instance document. Contexts, units, periods, segments, entities, facts, tuples etc.
– Constructor functions: allow dynamic creation of instance documents
– Taxonomy functions: allow navigation throw the taxonomy and linkbases
– Utility functions: files in the DTS etc…
Haga clic para cambiar el estilo de título
Haga clic para modificar el estilo de subtítulo del patrón
© 2006 XBRL International, All Rights Reserved www.xbrl.org/Legal
Using the XBRL functions library
• They are ‘low level’ functions
• Required to start building ‘high level’ functions
• Running the example …
Haga clic para cambiar el estilo de título
Haga clic para modificar el estilo de subtítulo del patrón
© 2006 XBRL International, All Rights Reserved www.xbrl.org/Legal
Thank you!