2

I'm trying to validate an XBRL document, but I'm a bit lost. The XBRL is a (simplified) example of the Dutch taxonomy for company tax submits. Here's the XBRL:

string xbrl = @"<xbrli:xbrl xml:lang='nl' 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:bd-alg='http://www.nltaxonomie.nl/8.0/basis/bd/items/bd-algemeen' xmlns:xbrldi='http://xbrl.org/2006/xbrldi' xmlns:bd-dim-dom='http://www.nltaxonomie.nl/8.0/basis/bd/domains/bd-domains' xmlns:bd-dim-dim='http://www.nltaxonomie.nl/8.0/domein/bd/axes/bd-axes' xmlns:bd-bedr='http://www.nltaxonomie.nl/8.0/basis/bd/items/bd-bedrijven' xmlns:iso4217='http://www.xbrl.org/2003/iso4217'>
<link:schemaRef xlink:type='simple' xlink:href='http://www.nltaxonomie.nl/8.0/report/bd/entrypoints/bd-rpt-vpb-aangifte-2013.xsd' xlink:arcrole='http://www.w3.org/1999/xlink/properties/linkbase'/>
<xbrli:context id='c1'>
    <xbrli:entity>
        <xbrli:identifier scheme='www.belastingdienst.nl/identificatie'>800030357</xbrli:identifier>
    </xbrli:entity>
    <xbrli:period>
        <xbrli:startDate>2013-07-01</xbrli:startDate>
        <xbrli:endDate>2014-06-01</xbrli:endDate>
    </xbrli:period>
    <xbrli:scenario>
        <xbrldi:explicitMember dimension='bd-dim-dim:PartyDimension'>bd-dim-dom:Declarant</xbrldi:explicitMember>
    </xbrli:scenario>
</xbrli:context>
<xbrli:context id='c2'>
    <xbrli:entity>
        <xbrli:identifier scheme='www.belastingdienst.nl/identificatie'>800030357</xbrli:identifier>
    </xbrli:entity>
    <xbrli:period>
        <xbrli:instant>2014-06-01</xbrli:instant>
    </xbrli:period>
    <xbrli:scenario>
        <xbrldi:explicitMember dimension='bd-dim-dim:TimeDimension'>bd-dim-dom:End</xbrldi:explicitMember>
        <xbrldi:explicitMember dimension='bd-dim-dim:PartyDimension'>bd-dim-dom:Declarant</xbrldi:explicitMember>
    </xbrli:scenario>
</xbrli:context>
<xbrli:unit id='u1'>
    <xbrli:measure>iso4217:EUR</xbrli:measure>
</xbrli:unit>
<bd-alg:SoftwarePackageName contextRef='c1'>SoftwareNaame</bd-alg:SoftwarePackageName>
<bd-alg:SoftwarePackageVersion contextRef='c1'>V1</bd-alg:SoftwarePackageVersion>
<bd-alg:TaxReturnMessageType contextRef='c1'>81</bd-alg:TaxReturnMessageType>
<bd-bedr:AssetsTotalAmountFiscal contextRef='c2' decimals='INF' unitRef='u1'>0</bd-bedr:AssetsTotalAmountFiscal>
<bd-bedr:BalanceProfitCalculationForTaxPurposesFiscal contextRef='c1' decimals='INF' unitRef='u1'>0</bd-bedr:BalanceProfitCalculationForTaxPurposesFiscal>
</xbrli:xbrl>";

I use the following code to load the XSD and validate the document:

var doc = XDocument.Parse(xbrl);
var xmlReader =  XmlReader.Create("http://www.nltaxonomie.nl/8.0/report/bd/entrypoints/bd-rpt-vpb-aangifte-2013.xsd");
var schema = XmlSchema.Read(xmlReader,
(sender, e) => { throw e.Exception; });

var set = new XmlSchemaSet();
set.Add(schema);
set.Compile();

doc.Validate(set, (sender, e) =>
{
    throw new Exception("document validation failed: " + e.Message);
});

This produces the following error message:

document validation failed: The element 'xbrl' in namespace 'http://www.xbrl.org/2003/instance' has invalid child element 'SoftwarePackageName' in namespace 'http://www.nltaxonomie.nl/8.0/basis/bd/items/bd-algemeen'. List of possible elements expected: 'item, tuple, context, unit' in namespace 'http://www.xbrl.org/2003/instance' as well as 'footnoteLink' in namespace 'http://www.xbrl.org/2003/linkbase'.

Apparantly SchemaSet.Compile fails to find all the related XSD's (direct link to the main XSD here). I've been trying different ways of loading the schema and parsing the document for hours now, but I'm not sure how to solve this problem.

I have also tried to read the document with Gepsio. Gepsio loads the document, but doesn't find any facts in the document, so it looks like the structure of the Dutch taxonomy schema is the problem here.

Hanno
  • 1,017
  • 11
  • 18
  • I am Gepsio's author. I will load this document instance with Gepsio and do some debugging to find out why no facts are being returned. Perhaps the debugging will give you some insight. Feel free to email the Gepsio project at Gepsio@outlook.com with more information. – JeffFerguson Jun 13 '14 at 17:05
  • Hi @JeffFerguson, I have already fixed it :) I took your source code and modified it to work with the Dutch taxonomy. What I had to do was the following: 1. In the XbrlSchema class constructor, call LookForAnnotations() right after ReadSchemaNode(). 2. Loop through all Locators in DefinitionLinks to find more XSD's. 3. After that I was still missing schema's, they are found in presentationLinks so I added new classes for that. This gave me a list of schemas to add to the set. 4. The Dutch taxonomy uses a 'specificationTuple and a 'presentationTuple', I've added those as well. – Hanno Jun 15 '14 at 10:23
  • Hi @Hanno ... that's great news! – JeffFerguson Jun 16 '14 at 16:10
  • Where can I get a copy of the Dutch taxonomy and a sample instance? I'd like to make sure that the official Gepsio release supports it. Feel free to email samples to gepsio@outlook.com ... thanks so much! – JeffFerguson Jun 16 '14 at 16:11
  • Hi guys, i´m having the same issue but with taxonomy nl 9.0, the problem is the same. can you help me? – Fábio Correia Jan 19 '16 at 11:43

1 Answers1

0

Your XML instance does not validate with that schema. Perhaps it will validate with another schema which imports it, or perhaps you need to create a new schema which imports all the schemas you need.

The problem is that these elements, placed at top level below root, at the end of your file:

<bd-alg:SoftwarePackageName contextRef='c1'>SoftwareNaame</bd-alg:SoftwarePackageName>
<bd-alg:SoftwarePackageVersion contextRef='c1'>V1</bd-alg:SoftwarePackageVersion>
<bd-alg:TaxReturnMessageType contextRef='c1'>81</bd-alg:TaxReturnMessageType>
<bd-bedr:AssetsTotalAmountFiscal contextRef='c2' decimals='INF' unitRef='u1'>0</bd-bedr:AssetsTotalAmountFiscal>
<bd-bedr:BalanceProfitCalculationForTaxPurposesFiscal contextRef='c1' decimals='INF' unitRef='u1'>0</bd-bedr:BalanceProfitCalculationForTaxPurposesFiscal>

are not allowed, according to the schema.

If you believe they should be allowed, probably you are not using the correct schema.

If your application can use a derived type, a solution would be to create a new schema which imports the schema you need, and defines a new root (in a new namespace) which allows the extra elements. If the types in the original schema are exposed, you can also try to redefine the root type in the same namespace.

helderdarocha
  • 23,209
  • 4
  • 50
  • 65
  • 1
    The thing is that these elements are definied in other XSD's. Looking at the main XSD, it contains links to other definition files, e.g. ' ' , that file contains the link locators to actual elements. See for example [this file](http://www.nltaxonomie.nl/8.0/report/bd/linkroles/bd-voorblad-pre.xml). Together with the other links in the main XSD it forms the complete taxonomy. – Hanno Jun 06 '14 at 08:24
  • Yes. The elements themselves are not invalid. They are misplaced since the `` element does not allow them as children (its XSD does not support the inclusion of arbitrary elements from other namespaces - only the elements that are declared there). You could have both in the same document if you place them as children of a different *root* node, and create a schema to validate that. Is that an option? – helderdarocha Jun 06 '14 at 16:21