title: How to ease extraction of meticulously specified XML data?
body: <p>There are some XML data files that I need to extract data from, along with an XSD that describes their structure. It uses lots of complex types from a couple of namespaces, which themselves use more complex types from more namespaces and so on. Even after flattening, still 120 XSDs are used.</p>
  
  <p>Here's the XSD:</p>
  
  <p>
      
      
      
      
      
  
  <pre><code>Copyright (C) UN/CEFACT (2008). All Rights Reserved.
  
  This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this paragraph are included on all such copies and derivative works. However, this document itself may not be modified in any way, such as by removing the copyright notice or references to UN/CEFACT, except as needed for the purpose of developing UN/CEFACT specifications, in which case the procedures for copyrights defined in the UN/CEFACT Intellectual Property Rights document must be followed, or as required to translate it into languages other than English.
  
  The limited permissions granted above are perpetual and will not be revoked by UN/CEFACT or its successors or assigns.
  
  This document and the information contained herein is provided on an "AS IS" basis and UN/CEFACT DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
  --&gt;
  &lt;!--
  Schema agency:   Florecom / Floricode
  Schema version:   0.10
  Schema date:       27 september 2013
  
  Copyright (C) Florecom / Floricode (2013). All Rights Reserved.
  
  Sierteelt Invoice
  
  20110510 HvR Upgrade to new Florecom Library RABIE4p0
  20110831 HvR Upgrade to development library RABIE5p0 for Pilot FloraHolland Invoice, added PayerParty, InvoicerParty
  20120507 HvR Library 2012 juli.
  20120612 HvR Upgrade to new Florecom library RABIE6p0. 
  20130927 HvR Upgrade to new Florecom / Floricode liberary RABIE7p0, added ClearingAgent.
  --&gt;
  &lt;xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:feccii="urn:fec:florecom:xml:data:draft:CrossIndustryInvoice:10" xmlns:ram="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:3" xmlns:feram="urn:fec:florecom:xml:data:draft:ReusableAggregateBusinessInformationEntity:7" xmlns:udt="urn:un:unece:uncefact:data:standard:UnqualifiedDataType:4" xmlns:qdt="urn:un:unece:uncefact:data:standard:QualifiedDataType:3" xmlns:ccts="urn:un:unece:uncefact:data:standard:CoreComponentsTechnicalSpecification:2" targetNamespace="urn:fec:florecom:xml:data:draft:CrossIndustryInvoice:10" elementFormDefault="qualified" attributeFormDefault="unqualified" version="0.10"&gt;
      &lt;!-- ======================================================================= --&gt;
      &lt;!-- =====  Imports                                                     ==== --&gt;
      &lt;!-- ======================================================================= --&gt;
      &lt;!-- =====  Import of Reusable Aggregate Business Information Entity Schema Module ===== --&gt;
      &lt;!-- ======================================================================= --&gt;
      &lt;xsd:import namespace="urn:un:unece:uncefact:data:standard:UnqualifiedDataType:4" schemaLocation="http://www.unece.org/uncefact/data/standard/UnqualifiedDataType_4p0.xsd"/&gt;
      &lt;!-- ======================================================================= --&gt;
      &lt;!-- ===== Import of Qualified DataType Schema Module                  ===== --&gt;
      &lt;!-- ======================================================================= --&gt;
      &lt;xsd:import namespace="urn:un:unece:uncefact:data:standard:QualifiedDataType:3" schemaLocation="http://www.unece.org/uncefact/data/standard/QualifiedDataType_3p0.xsd"/&gt;
      &lt;!-- ======================================================================= --&gt;
      &lt;!-- ===== Import of Reusable Aggregate Business Information Entity Schema Module ===== --&gt;
      &lt;!-- ======================================================================= --&gt;
      &lt;xsd:import namespace="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:3" schemaLocation="http://www.unece.org/uncefact/data/standard/ReusableAggregateBusinessInformationEntity_3p0.xsd"/&gt;
      &lt;!-- ======================================================================= --&gt;
      &lt;!-- ===== Import of FEC Reusable Aggregate Business Information Entity Schema Module ===== --&gt;
      &lt;!-- ======================================================================= --&gt;
      &lt;xsd:import namespace="urn:fec:florecom:xml:data:draft:ReusableAggregateBusinessInformationEntity:7" schemaLocation="http://schemas.florecom.org/xml/data/draft/FEC_ReusableAggregateBusinessInformationEntity_7p0.xsd"/&gt;
      &lt;!-- ======================================================================= --&gt;
      &lt;!-- =====  Element Declarations                                       ===== --&gt;
      &lt;!-- ======================================================================= --&gt;
      &lt;!-- =====  Root Element Declarations                      ===== --&gt;
      &lt;!-- ======================================================================= --&gt;
      &lt;xsd:element name="CrossIndustryInvoice" type="feccii:CrossIndustryInvoiceType"&gt;
          &lt;xsd:annotation&gt;
              &lt;xsd:documentation xml:lang="en"&gt;
                  &lt;ccts:UniqueID&gt;UNMCII1&lt;/ccts:UniqueID&gt;
                  &lt;ccts:Acronym&gt;CII&lt;/ccts:Acronym&gt;
                  &lt;ccts:Name&gt;CrossIndustryInvoice&lt;/ccts:Name&gt;
                  &lt;ccts:Version&gt;1.0&lt;/ccts:Version&gt;
                  &lt;ccts:Definition&gt;The cross industry invoice is an electronic document exchanged between trading partners with a prime function as a request for payment.  It is an important accounting document and has potential legal implications for sender and receiver. It is also used in the European Union as the key document for VAT declaration and reclamation, for statistics declaration in respect of intra community trade, and to support export and import declaration in respect of trade with countries outside the European community.&lt;/ccts:Definition&gt;
              &lt;/xsd:documentation&gt;
          &lt;/xsd:annotation&gt;
      &lt;/xsd:element&gt;
      &lt;!-- ================================================================== --&gt;
      &lt;!-- =====  Type Definitions                                      ===== --&gt;
      &lt;!-- ================================================================== --&gt;
      &lt;!-- =====  Type Definitions: CrossIndustryInvoiceType        ===== --&gt;
      &lt;!-- ================================================================== --&gt;
      &lt;xsd:complexType name="CrossIndustryInvoiceType"&gt;
          &lt;xsd:sequence&gt;
              &lt;xsd:element name="SupplierParty" type="ram:SupplierPartyType" minOccurs="0"/&gt;
              &lt;xsd:element name="CustomerParty" type="ram:CustomerPartyType" minOccurs="0"/&gt;
              &lt;xsd:element name="BuyerParty" type="ram:BuyerPartyType" minOccurs="0"/&gt;
              &lt;xsd:element name="SellerParty" type="ram:SellerPartyType" minOccurs="0"/&gt;
              &lt;xsd:element name="ConsignorParty" type="ram:ConsignorPartyType" minOccurs="0"/&gt;
              &lt;xsd:element name="ConsigneeParty" type="ram:ConsigneePartyType" minOccurs="0"/&gt;
              &lt;xsd:element name="InvoiceeParty" type="ram:InvoiceePartyType" minOccurs="0"/&gt;
              &lt;xsd:element name="InvoicerParty" type="feram:InvoicerPartyType" minOccurs="0"/&gt;
              &lt;xsd:element name="ManufacturerParty" type="ram:ManufacturerPartyType" minOccurs="0"/&gt;
              &lt;xsd:element name="PayeeParty" type="ram:PayeePartyType" minOccurs="0"/&gt;
              &lt;xsd:element name="PayerParty" type="feram:PayerPartyType" minOccurs="0"/&gt;
              &lt;xsd:element name="InvoiceIssuerParty" type="ram:InvoiceIssuerPartyType" minOccurs="0"/&gt;
              &lt;xsd:element name="TaxRepresentativeParty" type="ram:TaxRepresentativePartyType" minOccurs="0"/&gt;
              &lt;xsd:element name="CustomerAccountantParty" type="ram:CustomerAccountantPartyType" minOccurs="0"/&gt;
              &lt;xsd:element name="SupplierAccountantParty" type="ram:SupplierAccountantPartyType" minOccurs="0"/&gt;
              &lt;xsd:element name="ClearingAgentParty" type="feram:ClearingAgentPartyType" minOccurs="0"/&gt;
              &lt;xsd:element name="InvoiceTradeLineItem" type="feram:InvoiceTradeLineItemType" minOccurs="0" maxOccurs="unbounded"/&gt;
              &lt;xsd:element name="BillingPeriod" type="ram:BillingPeriodType" minOccurs="0" maxOccurs="unbounded"/&gt;
              &lt;xsd:element name="TradeTransportMeans" type="ram:TradeTransportMeansType" minOccurs="0"/&gt;
              &lt;xsd:element name="TradeTransportMode" type="ram:TradeTransportModeType" minOccurs="0"/&gt;
              &lt;xsd:element name="PayableAccountingAccount" type="ram:PayableAccountingAccountType" minOccurs="0" maxOccurs="unbounded"/&gt;
              &lt;xsd:element name="ReceivableAccountingAccount" type="ram:ReceivableAccountingAccountType" minOccurs="0" maxOccurs="unbounded"/&gt;
              &lt;xsd:element name="BillingCurrencyExchange" type="ram:BillingCurrencyExchangeType" minOccurs="0"/&gt;
              &lt;xsd:element name="PaymentCurrencyExchange" type="ram:PaymentCurrencyExchangeType" minOccurs="0"/&gt;
              &lt;xsd:element name="AlternativePaymentCurrencyExchange" type="ram:AlternativePaymentCurrencyExchangeType" minOccurs="0"/&gt;
              &lt;xsd:element name="TaxCurrencyExchange" type="ram:TaxCurrencyExchangeType" minOccurs="0"/&gt;
              &lt;xsd:element name="PayeeFinancialAccount" type="ram:PayeeFinancialAccountType" minOccurs="0" maxOccurs="unbounded"/&gt;
              &lt;xsd:element name="TradeAllowanceCharge" type="ram:TradeAllowanceChargeType" minOccurs="0" maxOccurs="unbounded"/&gt;
              &lt;xsd:element name="BillingAdjustment" type="ram:BillingAdjustmentType" minOccurs="0" maxOccurs="unbounded"/&gt;
              &lt;xsd:element name="TradeNote" type="ram:TradeNoteType" minOccurs="0" maxOccurs="unbounded"/&gt;
              &lt;xsd:element name="TradeDeliveryTerms" type="ram:TradeDeliveryTermsType" minOccurs="0"/&gt;
              &lt;xsd:element name="BillingDocument" type="feram:BillingDocumentType"/&gt;
              &lt;xsd:element name="BillingPayment" type="ram:BillingPaymentType" minOccurs="0" maxOccurs="unbounded"/&gt;
              &lt;xsd:element name="AdvancePayment" type="ram:AdvancePaymentType" minOccurs="0" maxOccurs="unbounded"/&gt;
              &lt;xsd:element name="ReferencedDocument" type="ram:ReferencedDocumentType" minOccurs="0" maxOccurs="unbounded"/&gt;
              &lt;xsd:element name="BillingMonetarySummation" type="ram:BillingMonetarySummationType" minOccurs="0"/&gt;
              &lt;xsd:element name="CategorySubtotalTax" type="ram:CategorySubtotalTaxType" minOccurs="0" maxOccurs="unbounded"/&gt;
          &lt;/xsd:sequence&gt;
      &lt;/xsd:complexType&gt;
  &lt;/xsd:schema&gt;
  </code></pre>
  
  <p>The actual data file I unfortunately cannot share, but it validates. (Scrambling it would break the validation.)</p>
  
  <p>I need a convenient way to extract the data from these in Delphi code.</p>
  
  <ul>
  <li>I tried the XML Data Binding wizard with the XSD, but it does not manage to spit out compiling code; just lots and lots of interfaces for what is essentially a simple data type.</li>
  <li>Generating it from the XML data file does result in compiling code that gives back simple data types but the data is blank.</li>
  <li>Having found about some problems with name spaces I adjusted the <code>RegisterChildNode</code> and <code>ChildNodes</code> calls to pass a blank string for the namespace (which does help when parsing by hand). Now I get interface casting errors.</li>
  </ul>
  
  <p>Is there any hope of getting this generator to work? Perhaps the structure is just too complicated, and I don't really need two-way binding. What I'm looking for is a readable (map/dictionary-like?) way of extracting the data (not dominated by the particularities of XML). Type-safety is not a must.</p>
  
  <p>It's not necessarily a Delphi-centered question. I'm afraid XSD.exe wouldn't do a much better job for .NET. Perhaps anyone can share experience with that to make my job easier </p>