Calculation Arc Conflicts and Precedence

The 331-equivalentRelationships-instance-02.xml conformance test in the XBRL-CONF-2014-12-10 conformance suite presents another opportunity for Gepsio to improve in its next version.

The landscape for this test, with regards to calculation arcs, is as follows:

  • the document instance contains a schema reference
  • the schema reference contains a calculation linkbase reference
  • the calculation linkbase reference referenced in the schema contains three locators for elements t_P1, t_P2, and t_P3
  • the calculation linkbase reference referenced in the schema contains an optional calculation arc from t_P1 to t_P2 and a second optional calculation arc from t_P1 to t_P3

This all defines a summation of t_P1 = t_P2 + t_P3. With me so far? Good.

The trick is that the XBRL instance itself references a second calculation linkbase, and that linkbase contains two locators, one for t_P1 and one for t_P3, as well as a prohibited calculation arc from t_P1 to t_P3.

What this test offers, therefore, is two arcs with conflicting information. Which one takes precedent? The calculation linkbase from the schema reference says that t_P1 = t_P2 + t_P3 but the calculation linkbase from the XBRL instance itself says that the arc from t_P1 to t_P3 is prohibited, which would basically invalidate the equation and prevent the calculation from being made since one of its arcs is prohibited.

This all presents an opportunity for Gepsio. In Gepsio 2.1.0.15 (which is the current version as of this writing), only calculation linkbases pulled from schema references are considered, and the calculation linkbase validation reference doesn’t consider any information from calculation linkbases pulled directly from XBRL instances. This conformance test proves that Gepsio is in error in this design and that it must consider all calculation linkbases found throughout the XBRL instance.

The XBRL Specification does not seem to specify what happens in this situation, in which there are two calculation linkbases with conflicting information in them. From the test itself, it can be inferred that the actual approach is that any information in the XBRL instance itself takes precedence over the information pulled from a schema reference. If a reader can point to a source that explicitly describes this assumption, then – by all means – feel free to leave a comment and describe where that information can be found.

To get this conformance test to pass, Gepsio will need to abide by a couple of new designs:

  • the calculation linkbase validation engine must consider calculation linkbase information pulled from the XBRL instance as well as information pulled from within schema references
  • the calculation linkbase validation engine must give precedence to linkbase information pulled from the XBRL instance over the information pulled from within schema references when there is a conflict between the two linkbases

This will be the next bit of work for Gepsio.

For those interested in the details of the test, here are the relevant files. It begins with the XBRL instance itself:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2008 XBRL International. All Rights Reserved. -->
<xbrl 
xmlns="http://www.xbrl.org/2003/instance" 
xmlns:t="http://xbrl.org/conformance/example" 
xmlns:link="http://www.xbrl.org/2003/linkbase" 
xmlns:xlink="http://www.w3.org/1999/xlink" 
>
  
  <link:schemaRef 
    xlink:type="simple" 
    xlink:href="331-equivalentRelationships-01.xsd"/>

 <link:linkbaseRef 
    xlink:type="simple"
    xlink:arcrole="http://www.w3.org/1999/xlink/properties/linkbase"
    xlink:href="331-equivalentRelationships-02-calculation.xml" />

  <context id="c-V01">
    <entity>
      <identifier scheme="http://xbrl.org/entity/identification/scheme">01</identifier>
    </entity>
    <period>
      <instant>2007-12-31</instant>
    </period>
  </context>  

  <unit id="pure">
    <measure>pure</measure>
  </unit>

  <t:P1 contextRef="c-V01" unitRef="pure" decimals="0">111</t:P1>
  <t:P2 contextRef="c-V01" unitRef="pure" decimals="0">111</t:P2>
  <t:P3 contextRef="c-V01" unitRef="pure" decimals="0">999</t:P3>


</xbrl>

The referenced schema is as follows:

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2008 XBRL International. All Rights Reserved. -->
<schema
  xmlns="http://www.w3.org/2001/XMLSchema"
  xmlns:xbrli="http://www.xbrl.org/2003/instance"
  xmlns:link="http://www.xbrl.org/2003/linkbase"
  xmlns:xlink="http://www.w3.org/1999/xlink"
  xmlns:t="http://xbrl.org/conformance/example"
  targetNamespace="http://xbrl.org/conformance/example"
  elementFormDefault="qualified"
  attributeFormDefault="unqualified">
  <annotation>
    <appinfo>
      <link:linkbaseRef xlink:type="simple"
        xlink:role="http://www.xbrl.org/2003/role/calculationLinkbaseRef"
        xlink:arcrole="http://www.w3.org/1999/xlink/properties/linkbase"
        xlink:href="331-equivalentRelationships-01-calculation.xml"
        xlink:title="Calculation Links, all" />
    </appinfo>
  </annotation>
  <import
    namespace="http://www.xbrl.org/2003/instance"
    schemaLocation="http://www.xbrl.org/2003/xbrl-instance-2003-12-31.xsd" />
  <element
    id="t_P1"
    name="P1"
    type="xbrli:decimalItemType"
    substitutionGroup="xbrli:item"
    xbrli:periodType="instant"
    nillable="true" />
  <element
    id="t_P2"
    name="P2"
    type="xbrli:decimalItemType"
    substitutionGroup="xbrli:item"
    xbrli:periodType="instant"
    nillable="true" />
  <element
    id="t_P3"
    name="P3"
    type="xbrli:decimalItemType"
    substitutionGroup="xbrli:item"
    xbrli:periodType="instant"
    nillable="true" />
  <attribute
    name="strAttr"
    type="string" />
  <attribute
    name="decAttr"
    type="decimal" />
  <attribute
    name="dblAttr"
    type="double" />
  <attribute
    name="boolAttr"
    type="boolean" />
  <attribute
    name="defaultAttr"
    type="string"
    default="pqr" />
  <attribute
    name="fixedAttr"
    type="string"
    fixed="xyz" />
</schema>

The calculation linkbase referenced by the schema is as follows:

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2008 XBRL International. All Rights Reserved. -->
<linkbase
  xmlns="http://www.xbrl.org/2003/linkbase"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:xlink="http://www.w3.org/1999/xlink"
  xmlns:t="http://xbrl.org/conformance/example"
  xsi:schemaLocation="
    http://www.xbrl.org/2003/linkbase 
      http://www.xbrl.org/2003/xbrl-linkbase-2003-12-31.xsd
    http://xbrl.org/conformance/example
      331-equivalentRelationships-01.xsd
    ">
  <calculationLink xlink:type="extended"
    xlink:role="http://www.xbrl.org/2003/role/link">
    <loc xlink:type="locator"
      xlink:label="t_P1"
      xlink:href="331-equivalentRelationships-01.xsd#t_P1" />
    <loc xlink:type="locator"
      xlink:label="t_P2"
      xlink:href="331-equivalentRelationships-01.xsd#t_P2" />
    <loc xlink:type="locator"
      xlink:label="t_P3"
      xlink:href="331-equivalentRelationships-01.xsd#t_P3" />
    <calculationArc xlink:type="arc"
      xlink:arcrole="http://www.xbrl.org/2003/arcrole/summation-item"
      xlink:from="t_P1" xlink:to="t_P2"
      order="1"
      weight="1"
      use="optional" />
    <calculationArc xlink:type="arc"
      xlink:arcrole="http://www.xbrl.org/2003/arcrole/summation-item"
      xlink:from="t_P1" xlink:to="t_P3"
      order="1"
      weight="1"
      use="optional" 
      t:strAttr="abc"
      t:decAttr="1.23"
      t:dblAttr="4.56"
      t:boolAttr="true"
      />
  </calculationLink>
</linkbase>

The calculation linkbase referenced in the XBRL instance, which contains the conflicting calculation arc, is as follows:

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2008 XBRL International. All Rights Reserved. -->
<linkbase
  xmlns="http://www.xbrl.org/2003/linkbase"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:xlink="http://www.w3.org/1999/xlink"
  xmlns:t="http://xbrl.org/conformance/example"
  xsi:schemaLocation="
    http://www.xbrl.org/2003/linkbase 
      http://www.xbrl.org/2003/xbrl-linkbase-2003-12-31.xsd
    http://xbrl.org/conformance/example
      331-equivalentRelationships-01.xsd
    ">
  <calculationLink xlink:type="extended"
    xlink:role="http://www.xbrl.org/2003/role/link">
    <loc xlink:type="locator"
      xlink:label="t_P1"
      xlink:href="331-equivalentRelationships-01.xsd#t_P1" />
    <loc xlink:type="locator"
      xlink:label="t_P3"
      xlink:href="331-equivalentRelationships-01.xsd#t_P3" />
    <calculationArc xlink:type="arc"
      xlink:arcrole="http://www.xbrl.org/2003/arcrole/summation-item"
      xlink:from="t_P1" xlink:to="t_P3"
      order="1"
      weight="1"
      priority="1"
      use="prohibited"
      t:strAttr="abc"
      t:decAttr="1.23"
      t:dblAttr="4.56"
      t:boolAttr="true"
      />
  </calculationLink>
</linkbase>

Inferring Linkbase Roles

Today, Gepsio uses the role attribute of a linkbaseRef node to determine the type of linkbase reference being referenced. Take, for example, the following linkbase reference, found in the 331-equivalentRelationships-01.xsd file in the XBRL-CONF-2014-12-10 conformance suite:

      <link:linkbaseRef xlink:type="simple"
        xlink:role="http://www.xbrl.org/2003/role/calculationLinkbaseRef"
        xlink:arcrole="http://www.w3.org/1999/xlink/properties/linkbase"
        xlink:href="331-equivalentRelationships-01-calculation.xml"
        xlink:title="Calculation Links, all" />

The value of the role attribute is http://www.xbrl.org/2003/role/calculationLinkbaseRef, which informs Gepsio that the linkbase reference is a calculation linkbase reference. Gepsio responds to that hint by creating a CalculationLinkbaseDocument object and populating it with the data in the reference.

In Gepsio version 2.1.0.15 (which, as of this writing, is the most recent version on NuGet), if the value of a role attribute of a linkbase reference is not one of the known URIs, or it does not have a value, Gepsio ignores the reference and doesn’t load anything. This, however, causes problems with some conformance suite tests that do not specify the role attribute. Take, for example, the following linkbase reference, found in the 331-equivalentRelationships-instance-02.xml file in the XBRL-CONF-2014-12-10 conformance suite:

 <link:linkbaseRef 
    xlink:type="simple"
    xlink:arcrole="http://www.w3.org/1999/xlink/properties/linkbase"
    xlink:href="331-equivalentRelationships-02-calculation.xml" />

This linkbase reference doesn’t even specify a role attribute, which means that, as of today, Gepsio skips over it, since it doesn’t know what role the reference plays. This reference, however, is critical to the conditions of this particular test, so Gepsio will need to be able to handle this situation.

The next version of Gepsio, therefore, will add support for inferring the correct role for a linkbase reference when the role attribute is either missing or contains a URI that does not match any of the standard linkbase reference roles. Gepsio will load the reference and will examine the nodes to determine the correct role for the reference. It will then load the appropriate object model reference and make the object available to the loaded instance’s object model in the same way that it would if a role attribute were properly specified.