title: XML schema parsing from XBRL schemaRef
body: <p>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:</p>
  
  <pre><code>string xbrl = @"&lt;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'&gt;
  &lt;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'/&gt;
  &lt;xbrli:context id='c1'&gt;
      &lt;xbrli:entity&gt;
          &lt;xbrli:identifier scheme='www.belastingdienst.nl/identificatie'&gt;800030357&lt;/xbrli:identifier&gt;
      &lt;/xbrli:entity&gt;
      &lt;xbrli:period&gt;
          &lt;xbrli:startDate&gt;2013-07-01&lt;/xbrli:startDate&gt;
          &lt;xbrli:endDate&gt;2014-06-01&lt;/xbrli:endDate&gt;
      &lt;/xbrli:period&gt;
      &lt;xbrli:scenario&gt;
          &lt;xbrldi:explicitMember dimension='bd-dim-dim:PartyDimension'&gt;bd-dim-dom:Declarant&lt;/xbrldi:explicitMember&gt;
      &lt;/xbrli:scenario&gt;
  &lt;/xbrli:context&gt;
  &lt;xbrli:context id='c2'&gt;
      &lt;xbrli:entity&gt;
          &lt;xbrli:identifier scheme='www.belastingdienst.nl/identificatie'&gt;800030357&lt;/xbrli:identifier&gt;
      &lt;/xbrli:entity&gt;
      &lt;xbrli:period&gt;
          &lt;xbrli:instant&gt;2014-06-01&lt;/xbrli:instant&gt;
      &lt;/xbrli:period&gt;
      &lt;xbrli:scenario&gt;
          &lt;xbrldi:explicitMember dimension='bd-dim-dim:TimeDimension'&gt;bd-dim-dom:End&lt;/xbrldi:explicitMember&gt;
          &lt;xbrldi:explicitMember dimension='bd-dim-dim:PartyDimension'&gt;bd-dim-dom:Declarant&lt;/xbrldi:explicitMember&gt;
      &lt;/xbrli:scenario&gt;
  &lt;/xbrli:context&gt;
  &lt;xbrli:unit id='u1'&gt;
      &lt;xbrli:measure&gt;iso4217:EUR&lt;/xbrli:measure&gt;
  &lt;/xbrli:unit&gt;
  &lt;bd-alg:SoftwarePackageName contextRef='c1'&gt;SoftwareNaame&lt;/bd-alg:SoftwarePackageName&gt;
  &lt;bd-alg:SoftwarePackageVersion contextRef='c1'&gt;V1&lt;/bd-alg:SoftwarePackageVersion&gt;
  &lt;bd-alg:TaxReturnMessageType contextRef='c1'&gt;81&lt;/bd-alg:TaxReturnMessageType&gt;
  &lt;bd-bedr:AssetsTotalAmountFiscal contextRef='c2' decimals='INF' unitRef='u1'&gt;0&lt;/bd-bedr:AssetsTotalAmountFiscal&gt;
  &lt;bd-bedr:BalanceProfitCalculationForTaxPurposesFiscal contextRef='c1' decimals='INF' unitRef='u1'&gt;0&lt;/bd-bedr:BalanceProfitCalculationForTaxPurposesFiscal&gt;
  &lt;/xbrli:xbrl&gt;";
  </code></pre>
  
  <p>I use the following code to load the XSD and validate the document:</p>
  
  <pre><code>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) =&gt; { throw e.Exception; });
  
  var set = new XmlSchemaSet();
  set.Add(schema);
  set.Compile();
  
  doc.Validate(set, (sender, e) =&gt;
  {
      throw new Exception("document validation failed: " + e.Message);
  });
  </code></pre>
  
  <p>This produces the following error message:</p>
  
  <blockquote>
    <p>document validation failed: The element 'xbrl' in namespace '<a href="http://www.xbrl.org/2003/instance" rel="nofollow">http://www.xbrl.org/2003/instance</a>' has invalid child element 'SoftwarePackageName' in namespace '<a href="http://www.nltaxonomie.nl/8.0/basis/bd/items/bd-algemeen" rel="nofollow">http://www.nltaxonomie.nl/8.0/basis/bd/items/bd-algemeen</a>'. List of possible elements expected: 'item, tuple, context, unit' in namespace '<a href="http://www.xbrl.org/2003/instance" rel="nofollow">http://www.xbrl.org/2003/instance</a>' as well as 'footnoteLink' in namespace '<a href="http://www.xbrl.org/2003/linkbase" rel="nofollow">http://www.xbrl.org/2003/linkbase</a>'.</p>
  </blockquote>
  
  <p>Apparantly SchemaSet.Compile fails to find all the related XSD's (direct link to the main XSD <a href="http://www.nltaxonomie.nl/8.0/report/bd/entrypoints/bd-rpt-vpb-aangifte-2013.xsd" rel="nofollow">here</a>). 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. </p>
  
  <p>I have also tried to read the document with <a href="https://gepsio.codeplex.com/" rel="nofollow">Gepsio</a>. 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.</p>