xbrl formula linkbase introduction
DESCRIPTION
Paris,14.12.2012. XBRL Formula Linkbase Introduction. SDMX TWG (4th meeting in Paris OECD). Wojciech Ciebiera. Paris,14.12.2012. XBRL Linkbases. Current: Label Linkbase (Readable form of con c ept , languages) Reference Linkbase (Regulations) Calculation Linkbase (Simple summing) - PowerPoint PPT PresentationTRANSCRIPT
1
XBRL Formula Linkbase Introduction
SDMX TWG (4th meeting in Paris OECD)
Paris,14.12.2012
Wojciech Ciebiera
2
XBRL Linkbases
Paris,14.12.2012
Current:• Label Linkbase (Readable form of concept, languages)• Reference Linkbase (Regulations)• Calculation Linkbase (Simple summing)• Definition Linkbase (Relations between elements: dimensions, measures)• Presentation Linkbase (Not visual form! Rather order of elements)New:• Formula Linkbase (Assertions)• Rendering Linkbase (Visual form)
*Formula Linkbase is currently used in NBP Supervisory Statistics
3
SDMX vs. XBRL (XML schema structure)
Paris,14.12.2012
xs:s
chem
a
namespaces
Import/include
element
element
element
element
element
element
element
elementelement
xs:s
chem
a
namespaces
Import/include
element
element
element
element
element
element
element
element
SDMX schema XBRL schema
namespaces
Import/include
element
element
element
namespaces
Import/include
element
element
element
Linkbases
Label Linkbase
Formula Linkbase
xs:s
chem
a
namespaces
Import/include
element
element
element
element
element
element
element
elementelement
4
SDMX vs. XBRL (XML instance structure)
Paris,14.12.2012
root
namespaces
Import/include
element
element
element
elementelement
elementelement
element
root
namespaces
Import/include
element
element
element
element
element
element
element
<xbrli:context id=„@id">(ns:dimensions)
<ns:element contextRef=„@id">(unitRef,decimals)
SDMX instance XBRL instance
5
Profit = (1*Revenue) + (-1*Costs)<calculationArc xlink:type="arc" link:arcrole="http://www.xbrl.org/2003/arcrole/summation-item" xlink:from="Profit" xlink:to="Revenue" order="1" weight="1" use="optional"/> <calculationArc xlink:type="arc" xlink:arcrole="http://www.xbrl.org/2003/arcrole/summation-item" xlink:from="Profit" xlink:to="Costs" order="2" weight="-1" use="optional"/>
*attribute weight is of type „xs:decimal”
Older Calculation Linkbase (summation)
Paris,14.12.2012
6
Formula Linkbase functionality
Paris,14.12.2012
• Contain: Nodes, values, elements• General comparison: =, !=, <>• Values comparison: eq, ne, lt, le, gt, ge• Structures: if than else• Iterators: for• Aggregations: max(), min(), avg()• Cross-dependencies (i.e. in one file several reporters)• Thresholds• Local functions (local:function)• Predefined XBRL Functions 1.0
– xfi:period– xfi:entity– xfi:segment
7
Formula Linkbase (technologies)
Paris,14.12.2012
XQuery
XSLT
XLink
XPath
XPointerUsed in Formula Linkbase• XQuery• XPointer• XPath• XLink
Used in SDMX ExpressionsAnd Calculations• ?
8
XQuery FLWOR: FOR
Paris,14.12.2012
XQuery (FLWOR construction: For, Let, Where, Order, Return).
File.xml:<root> <element> <entry1>10</entry1> <entry2>OECD</entry2> </element> <element> <entry1>110</entry1> <entry2>NBP</entry2> </element> </root>
FOR code:for $item in doc('File.xml')/root/elementwhere $item/entry1>50return $item/entry2
FOR result:<?xml version='1.0' encoding='UTF-8'?><entry2>NBP</entry2>
9
XQuery FLWOR: LET, WHERE, ORDER, RETURN
Paris,14.12.2012
LET code:let $item :=(1 to 5) return<element>{$item}</element>LET result:<element>1 2 3 4 5</element>
WHERE code:for $item in (1 to 5) where $item = 3return<element>{$item}</element>WHERE result:<element>3</element>
ORDER code:Let $item in ('Xavier','Wojciech','Jens','Chris')Order by $item return<name>{$item}</name>ORDER result:<name>Chris</name><name>Jens</name><name>Wojciech</name><name>Xavier</name>
10
Types of assertions
Paris,14.12.2012
Formula validation:• Consistency assertion
– Precalculated values compared to real economic facts• Value assertion
– Math equations• Existence assertion
– Checking if the value is mandatory
11
Value Assertion (example)
Paris,14.12.2012
This is validation of PESEL ID (used in Poland):
<va:valueAssertion xlink:type="resource" xlink:label="valueAssertion" xlink:title="valueAssertion" id="valueAssertion" test="for $v in $v1 return (string-length($v) = 11 and matches($v, '^[0-9]{11}') and sum( for $i in 1 to 11 return (1,3,7,9,1,3,7,9,1,3,1)[$i] * number( substring( $v, $i, 1) ) ) mod 10 eq 0 )" aspectModel="dimensional" implicitFiltering="true"/><variable:generalVariable xlink:type="resource" xlink:label="generalVariable" xlink:title="generalVariable" id="UnitCode" select="//d-LE:UnitCode" bindAsSequence="false"/> <variable:variableArc xlink:type="arc" xlink:arcrole="http://xbrl.org/arcrole/2008/variable-set" xlink:from="valueAssertion" xlink:to="generalVariable" xlink:title="valueAssertion to generalVariable" priority="0" order="1.0" name="v1"/>
*Formula Linkbase is descriptive language rather than sequence code. Tests return value true or false.
12
Fujitsu Formula Editor for Formula Linkbase
Paris,14.12.2012
13
Current NBP Solution (Balance of Payment)
Paris,14.12.2012
XQuery
XSLT
XLink
XPath
XPointer
Solution used in NBP• Adobe LiveCycle• XSD• XSLT• XPath
XML FILE
XSDValidation XSLT
Validation
Sche
ma
Erro
r
Cal
cula
tion
Erro
r
14
Paris,14.12.2012
Thank you for you attention!
Questions?
Wojciech CiebieraEconomic ExpertDepartment of StatisticsNational Bank of Poland