title: How do you map a abstract XSD element in Xquery?
body: <p>I have a form that I am defining in my Xquery request. This form is built on an XSD schema. </p>
  
  <p><strong>My form:</strong></p>
  
  <pre><code>&lt;xsd:element name="AddInsuranceToOrderForm"&gt;
          &lt;xsd:complexType&gt;
                &lt;xsd:sequence&gt;
                      &lt;xsd:element name="OrderId" type="xsd:long" minOccurs="1" maxOccurs="1"/&gt;
                      &lt;xsd:element name="DistributionChannel" type="xsd:long" minOccurs="1" maxOccurs="1"/&gt;
                      &lt;xsd:element name="FloatNumber" type="xsd:long" minOccurs="1" maxOccurs="1"/&gt;
                      &lt;xsd:element name="UserId" type="xsd:long" minOccurs="1" maxOccurs="1"/&gt;
                      &lt;xsd:element name="SalesId" type="xsd:long" minOccurs="1" maxOccurs="1"/&gt;
                      &lt;xsd:element name="TotalDue" type="xsd:decimal" minOccurs="1" maxOccurs="1"/&gt;
                      &lt;xsd:element name="ChangeDue" type="xsd:decimal" minOccurs="1" maxOccurs="1"/&gt;
                      **&lt;xsd:element ref="tns:tenderItem" minOccurs="0" maxOccurs="unbounded"/&gt;**
                      &lt;xsd:element name="ProtectionPlans" type="tns:ProtectionPlanItemType" minOccurs="0" maxOccurs="unbounded"/&gt;
                      &lt;xsd:element name="InsurancePlans" type="tns:FeatureItemType" minOccurs="0" maxOccurs="unbounded"/&gt;
                &lt;/xsd:sequence&gt;
          &lt;/xsd:complexType&gt;
    &lt;/xsd:element&gt;
  </code></pre>
  
  <p><strong>Notice tenderItems is a ref. It's source is here:</strong></p>
  
  <pre><code>&lt;xsd:element abstract="true" name="tenderItem" type="tns:TenderType"/&gt;
    &lt;xsd:complexType name="TenderType"&gt;
          &lt;xsd:sequence&gt;
                &lt;xsd:element maxOccurs="1" minOccurs="0" name="date" type="xsd:dateTime"/&gt;
                &lt;xsd:element maxOccurs="1" minOccurs="0" name="lineNumber" type="xsd:string"/&gt;
                &lt;xsd:element maxOccurs="1" minOccurs="0" name="tenderId" type="xsd:long"/&gt;
                &lt;xsd:element maxOccurs="1" minOccurs="0" name="returnTenderId" type="xsd:long"/&gt;
                &lt;xsd:element maxOccurs="1" minOccurs="0" name="tenderType" type="tns:TenderTypeType"/&gt;
                &lt;xsd:element maxOccurs="1" minOccurs="0" name="amount" type="xsd:decimal"/&gt;
                &lt;xsd:element maxOccurs="1" minOccurs="0" name="signature" type="tns:SignatureType"/&gt;
          &lt;/xsd:sequence&gt;
    &lt;/xsd:complexType&gt;
  </code></pre>
  
  <p>There are several specific tenders that extend tenderType that I want to add to my Xquery request. <strong>Here is an example:</strong></p>
  
  <pre><code>      &lt;xsd:element name="billToAccount" substitutionGroup="tns:tenderItem" type="tns:BillToAccountType"/&gt;
    &lt;xsd:complexType name="BillToAccountType"&gt;
          &lt;xsd:complexContent&gt;
                &lt;xsd:extension base="tns:TenderType"&gt;
                      &lt;xsd:sequence&gt;
                            &lt;xsd:element maxOccurs="1" minOccurs="0" name="accountId" type="xsd:long"/&gt;
                            &lt;xsd:element maxOccurs="1" minOccurs="0" name="subscriptionId" type="xsd:string"/&gt;
                            &lt;xsd:element maxOccurs="1" minOccurs="0" name="chargeDescription" type="xsd:string"/&gt;
                            &lt;xsd:element maxOccurs="unbounded" minOccurs="0" name="lineItems" type="tns:BillToAccountLineItemType"/&gt;
                      &lt;/xsd:sequence&gt;
                &lt;/xsd:extension&gt;
          &lt;/xsd:complexContent&gt;
    &lt;/xsd:complexType&gt;
  </code></pre>
  
  <p><strong>So how is this done in Xquery? I've tried the following:</strong></p>
  
  <pre><code>{
      for $BillToAccount in $addInsuranceToOrderABM1/ns3:MessagePayload/ns3:AddInsuranceToOrder/ns1:AddInsuranceToOrderDataArea/ns2:TenderItem
          return
              &lt;ns2:billToAccount&gt;
                  {
                      for $Date in $BillToAccount/ns0:Date
                      return
                          &lt;ns2:date&gt;{ data($Date) }&lt;/ns2:date&gt;
                  }…
  }
  </code></pre>
  
  <p>I did this for each tenderType, but the XML elements are not supported by the mapper.</p>