2017-09-28 68 views
0

我想使用sqlxml批量加載器將大​​型xml文件加載到db。爲了做到這一點,我們必須更新模式文件。下面是schema文件:xsd架構不會正確處理文件xml

<?xml version="1.0" ?> 
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:sql="urn:schemas-microsoft-com:mapping-schema" 
      xmlns="http://www.eagleinvsys.com/2011/EagleML-2-0" > 

    <xsd:element name="EagleML" 
       xsi:type="WarehouseTransactionMessage" 
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 

       sql:is-constant="1" > 
    <xsd:complexType > 
     <xsd:sequence> 
    <!--<xsd:element name="header" sql:is-constant="1" /> 
    <xsd:element name="taskIdentifier" sql:is-constant="1" />--> 
    <xsd:element name="warehouseTransaction" sql:is-constant="1"> 
    <xsd:complexType > 
    <xsd:sequence> 
     <xsd:element name="warehouseOpenLot" sql:relation="TEST" > 
      <xsd:complexType> 
      <xsd:sequence> 
       <xsd:element name="accountingBasis" type="xsd:string" /> 
       </xsd:sequence> 
       <!--<xsd:attribute name="accruedLtdBase" type="xsd:decimal" /> 
      <xsd:attribute name="accruedLtdLocal" type="xsd:decimal" />--> 
      <!--<xsd:attribute name="xrateLocalBase" type="xsd:decimal" />--> 
      <!--<xsd:attribute name="buySellFlag" type="xsd:normalizedString" /> 
      <xsd:attribute name="closeTipsIncomeLtdBase" type="xsd:decimal" />--> 
     </xsd:complexType> 
     </xsd:element> 
    </xsd:sequence> 
    </xsd:complexType> 
    </xsd:element> 
     </xsd:sequence> 
    </xsd:complexType> 
    </xsd:element> 
</xsd:schema> 

這裏是XML文件

<EagleML 
eaglemlVersion="2-0" 
eaglemlType="WarehouseTransactionMessage" 
eaglemlRevision="263" 
xsi:schemaLocation="http://www.eagleinvsys.com/2011/EagleML-2-0 eagleml-main-2-0.xsd" 
xsi:type="WarehouseTransactionMessage" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns="http://www.eagleinvsys.com/2011/EagleML-2-0" 
> 
    <header> 
    <messageId>B70JFJ55EE9AVXOX</messageId> 
    <sentBy>http://www.eagleinvsys.com/</sentBy> 
    <creationTimestamp>2017-09-25T08:25:54-04:00</creationTimestamp> 
    </header> 
    <taskIdentifier> 
    <correlationId>JFJ55EE9TARJH009</correlationId> 
    <sequenceNumber>1</sequenceNumber> 
    </taskIdentifier> 
    <warehouseTransaction> 
     <header> 
     <objectType>WarehouseOpenLot</objectType> 
     </header> 
     <warehouseOpenLot> 
     <accountingBasis>USTAX</accountingBasis> 
     </warehouseOpenLot> 
     <warehouseOpenLot> 
     <accountingBasis>TESTT</accountingBasis> 
     </warehouseOpenLot> 
    </warehouseTransaction> 
    </EagleML> 

如果要是將這些標籤功能,它工作正常,但我沒有這樣做的奢侈品:

xsi:schemaLocation="http://www.eagleinvsys.com/2011/EagleML-2-0 eagleml-main-2-0.xsd" 
xsi:type="WarehouseTransactionMessage" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns="http://www.eagleinvsys.com/2011/EagleML-2-0" 

我在這裏做錯了什麼?我嘗試將這些標籤移動到EagleML元素中,但我似乎仍然無處可尋。有沒有人看到這個錯誤?

回答

0

模式描述特定名稱空間的XML詞彙表。如果模式中沒有targetNamespace屬性,它將描述一個沒有名稱空間的詞彙表。

您的實例文檔具有名稱空間聲明xmlns =「http://www.eagleinvsys.com/2011/EagleML-2-0」,它將EagleML及其所有子/後代放入該名稱空間中,而不是模式的targetNamespace。

不知道有關EagleML規範的任何信息,我不知道它是模式還是實例文檔是錯誤的,但我可以告訴你它們不匹配。最簡單的解決方法是將一個targetNamespace屬性添加到xs:schema元素。