Link to home
Start Free TrialLog in
Avatar of Simon Cripps
Simon CrippsFlag for United Kingdom of Great Britain and Northern Ireland

asked on

SQLXMLBULKLOAD relationship expected

XSD schema (abridged version attached) to map the SQL fields to, however I am getting a "Schema: relationship expected on 'prod'." error. This occurs on the sub element "prod". I have fixed on other XML feeds in the past by setting sql:is-constant="1", however this time the feed is supplied with attributes and so cannot be set as constant. I have set the file sql table relationship to "merchant" element and I am looking to write the data to just one SQL table "InputGlobalFeed" and so I believe should not require a relationship attribute set. Any suggestions most welcome.
<xsd:schema xmlns:sql="urn:schemas-microsoft-com:mapping-schema" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <xsd:element sql:is-constant="1" name="merchantProductFeed">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element sql:relation="InputGlobalFeed" minOccurs="0" name="merchant">
          <xsd:complexType>
            <xsd:sequence>
              <xsd:element minOccurs="0" maxOccurs="unbounded" name="prod">
                <xsd:complexType>
                  <xsd:sequence>
                    <xsd:element sql:field="IGFProgramId" minOccurs="0" name="pId" />
                    <xsd:element sql:field="IGFModel" minOccurs="0" name="modelNumber" />
                    <xsd:element sql:is-constant="1" minOccurs="0" name="text">
                      <xsd:complexType>
                        <xsd:sequence>
                          <xsd:element sql:field="IGFMerchantProductName" minOccurs="0" name="name" />
                          <xsd:element sql:field="IGFProductDescription" minOccurs="0" name="desc" />
                        </xsd:sequence>
                      </xsd:complexType>
                    </xsd:element> 
                    <xsd:element sql:field="IGFDeliveryTime" minOccurs="0" name="delTime" />
                    <xsd:element sql:field="IGFProductAdded" minOccurs="0" name="valFrom" />
                    <xsd:element minOccurs="0" name="valTo" />
                    <xsd:element minOccurs="0" name="comAmount" />
                  </xsd:sequence>
                  <xsd:attribute sql:field="IGFMerchantProductId" name="id" use="optional" />
                  <xsd:attribute name="pre_order" use="optional" />
                  <xsd:attribute sql:field="IGFPromoText" name="web_offer" use="optional" />
                  <xsd:attribute sql:field="IGFInStock" name="in_stock" use="optional" />
                  <xsd:attribute name="stock_quantity" use="optional" />
                </xsd:complexType>
              </xsd:element>
            </xsd:sequence>
            <xsd:attribute sql:field="IGFMerchantSiteId" name="id" use="optional" />
            <xsd:attribute sql:field="IGFMerchantName" name="name" use="optional" />
          </xsd:complexType>
        </xsd:element>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
</xsd:schema>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Simon Cripps
Simon Cripps
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial