160 likes | 458 Views
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)
E N D
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 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 Linkbaseiscurrentlyused in NBP SupervisoryStatistics
Paris,14.12.2012 SDMX vs. XBRL (XML schema structure) SDMX schema XBRL schema LabelLinkbase Linkbases FormulaLinkbase
Paris,14.12.2012 SDMX vs. XBRL (XML instance structure) SDMX instance XBRL instance <ns:elementcontextRef=„@id"> (unitRef,decimals) <xbrli:context id=„@id"> (ns:dimensions)
Paris,14.12.2012 OlderCalculation Linkbase (summation) Profit = (1*Revenue) + (-1*Costs) <calculationArcxlink:type="arc"link:arcrole="http://www.xbrl.org/2003/arcrole/summation-item"xlink:from="Profit"xlink:to="Revenue"order="1"weight="1"use="optional"/> <calculationArcxlink: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”
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 severalreporters) • Thresholds • Local functions (local:function) • Predefined XBRL Functions 1.0 • xfi:period • xfi:entity • xfi:segment
Paris,14.12.2012 Formula Linkbase (technologies) XPointer • Used in Formula Linkbase • XQuery • XPointer • XPath • XLink • Used in SDMX Expressions • And Calculations • ? XPath
Paris,14.12.2012 XQuery FLWOR: FOR 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/element where $item/entry1>50 return $item/entry2 FOR result: <?xml version='1.0' encoding='UTF-8'?> <entry2>NBP</entry2>
Paris,14.12.2012 XQuery FLWOR: LET, WHERE, ORDER, RETURN LET code: let$item :=(1to 5) return<element>{$item}</element> LET result: <element>1 2 3 4 5</element> WHERE code: for $item in (1to 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>
Paris,14.12.2012 Types of assertions Formulavalidation: • Consistencyassertion • Precalculatedvaluescompared to real economicfacts • Value assertion • Math equations • Existenceassertion • Checkingif the valueismandatory
Paris,14.12.2012 Value Assertion (example) Thisisvalidation of PESEL ID (used in Poland): <va:valueAssertionxlink: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:generalVariablexlink:type="resource"xlink:label="generalVariable"xlink:title="generalVariable"id="UnitCode"select="//d-LE:UnitCode"bindAsSequence="false"/> <variable:variableArcxlink:type="arc"xlink:arcrole="http://xbrl.org/arcrole/2008/variable-set"xlink:from="valueAssertion"xlink:to="generalVariable"xlink:title="valueAssertionto generalVariable"priority="0"order="1.0"name="v1"/> *FormulaLinkbaseisdescriptivelanguageratherthansequencecode. Tests return valuetrueorfalse.
Paris,14.12.2012 Fujitsu Formula Editor for FormulaLinkbase
Paris,14.12.2012 Current NBP Solution (Balance of Payment) • Solution usedin NBP • Adobe LiveCycle • XSD • XSLT • XPath • XQuery • XLink PDF • XSLT Schema Error XPointer XML FILE Calculation Error XPath XSD Validation XSLT Validation
Paris,14.12.2012 Thankyou for youattention! Questions? Wojciech Ciebiera EconomicExpert Department of Statistics National Bank of Poland