Formula Linkbase

Report
Paris,14.12.2012
XBRL Formula Linkbase Introduction
SDMX TWG (4th meeting in Paris OECD)
1
Wojciech Ciebiera
Paris,14.12.2012
XBRL Linkbases
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
2
Paris,14.12.2012
SDMX vs. XBRL (XML schema structure)
SDMX schema
XBRL schema
namespaces
xs:schema
namespaces
Import/include
element
element
element
Import/include
element
element
element
element
element
element
Import/include
element
element
element
element
element
xs:schema
xs:schema
namespaces
element
Import/include
element
element
element
Formula Linkbase
element
element
element
element
element
element
element
Linkbases
element
namespaces
element
Label Linkbase
namespaces
Import/include
element
element
element
element
element
3
Paris,14.12.2012
SDMX vs. XBRL (XML instance structure)
SDMX instance
XBRL instance
namespaces
namespaces
Import/include
element
element
element
element
element
element
element
root
root
Import/include
element
<ns:element [email protected]">
(unitRef,decimals)
element
element
element
element
element
element
element
<xbrli:context [email protected]">
(ns:dimensions)
4
Paris,14.12.2012
Older Calculation Linkbase (summation)
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”
5
Paris,14.12.2012
Formula Linkbase functionality
•
•
•
•
•
•
•
•
•
•
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
6
Paris,14.12.2012
Formula Linkbase (technologies)
XPointer
XQuery
XLink
XPath
XSLT
Used in Formula Linkbase
• XQuery
• XPointer
• XPath
• XLink
Used in SDMX Expressions
And Calculations
• ?
7
Paris,14.12.2012
XQuery FLWOR: FOR
XQuery (FLWOR construction: For, Let, Where, Order, Return).
File.xml:
FOR code:
<root>
<element>
<entry1>10</entry1>
<entry2>OECD</entry2>
</element>
<element>
<entry1>110</entry1>
<entry2>NBP</entry2>
</element>
</root>
for $item in doc('File.xml')/root/element
where $item/entry1>50
return $item/entry2
FOR result:
<?xml version='1.0' encoding='UTF-8'?>
<entry2>NBP</entry2>
8
Paris,14.12.2012
XQuery FLWOR: LET, WHERE, ORDER, RETURN
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 = 3
return<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>
9
Paris,14.12.2012
Types of assertions
Formula validation:
• Consistency assertion
–
•
Value assertion
–
•
Precalculated values compared to real economic facts
Math equations
Existence assertion
–
Checking if the value is mandatory
10
Paris,14.12.2012
Value Assertion (example)
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 (stringlength($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.
11
Paris,14.12.2012
Fujitsu Formula Editor for Formula Linkbase
12
Paris,14.12.2012
Current NBP Solution (Balance of Payment)
Solution used in NBP
• Adobe LiveCycle
• XSD
• XSLT
• XPath
XQuery
PDF
XPointer
XLink
XML
FILE
XPath
XSLT
XSD
Validation
XSLT
Validation
13
Paris,14.12.2012
Thank you for you attention!
Questions?
Wojciech Ciebiera
Economic Expert
Department of Statistics
National Bank of Poland
14

similar documents