2014-06-12 57 views
0

我已經根據OIOUBL標準創建了一個訂單XML文件,但是當我通過在線驗證工具(http://www.oioubl.info/validator/default.aspx)運行它時遇到了問題。錯誤消息如下:OIOUBL訂單XML文件失敗schematron驗證(XSLT) - DocumentType不匹配

Checking OIOUBL-2.02 Order, 2013-09-15, Version 1.5.0 
The document can not pass the schematron validation. 
1 error(s) occurred. 

Error No. : 1 
Context :/
Pattern : namespace-uri(*) = 'urn:oasis:names:specification:ubl:schema:xsd:Order-2' 
Description : [F-ORD254] The documenttype does not match an OIOUBL Order and can not be validated by this schematron. 
XPath : 

Fuld fejlbesked Xml : 
<Information>Checking OIOUBL-2.02 Order, 2013-09-15, Version 1.5.0</Information><Error context="/"><Pattern>namespace-uri(*) = 'urn:oasis:names:specification:ubl:schema:xsd:Order-2'</Pattern><Description>[F-ORD254] The documenttype does not match an OIOUBL Order and can not be validated by this schematron.</Description><Xpath /></Error> 

我一直沒能找到任何OIOUBL文件,以解釋如何糾正。希望得到一些幫助。

以下是XML文檔

<!-- language: lang-xml --> 
<?xml version="1.0" encoding="UTF-8"?> 
<Order xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"> 
<cbc:UBLVersionID>2.0</cbc:UBLVersionID> 
<cbc:CustomizationID>OIOUBL-2.02</cbc:CustomizationID> 
<cbc:ProfileID schemeID="urn:oioubl:id:profileid-1.2">Procurement-OrdSim-BilSim-1.0</cbc:ProfileID> 
<cbc:ID>Referencenummer</cbc:ID> 
<cbc:IssueDate>2014-06-12</cbc:IssueDate> 
<cbc:Note>THIS IS A TEST ORDER! </cbc:Note> 
<cac:BuyerCustomerParty> 
    <cac:Party> 
    <cbc:EndpointID schemeID="DK:CVR">hhw123456</cbc:EndpointID> 
    <cac:PartyIdentification> 
     <cbc:ID schemeID="DK:CVR">hhw123456</cbc:ID> 
    </cac:PartyIdentification> 
    <cac:PartyName> 
     <cbc:Name>HHW</cbc:Name> 
    </cac:PartyName> 
    <cac:PartyLegalEntity> 
     <cbc:RegistrationName>HHW</cbc:RegistrationName> 
     <cbc:CompanyID schemeID="DK:CVR">hhw123456</cbc:CompanyID> 
    </cac:PartyLegalEntity> 
    <cac:Contact> 
     <cbc:Name>He hongwei</cbc:Name> 
     <cbc:ElectronicMail>[email protected]</cbc:ElectronicMail> 
    </cac:Contact> 
    </cac:Party> 
</cac:BuyerCustomerParty><cac:SellerSupplierParty> 
    <cac:Party> 
    <cbc:EndpointID schemeID="DK:CVR">15908416</cbc:EndpointID> 
    <cac:PartyIdentification> 
     <cbc:ID schemeID="DK:CVR">15908416</cbc:ID> 
    </cac:PartyIdentification> 
    <cac:PartyName> 
     <cbc:Name>Solar</cbc:Name> 
    </cac:PartyName> 
    <cac:PartyLegalEntity> 
     <cbc:CompanyID schemeID="DK:CVR">15908416</cbc:CompanyID> 
    </cac:PartyLegalEntity> 
    </cac:Party> 
</cac:SellerSupplierParty><cac:AccountingCustomerParty> 
    <cbc:SupplierAssignedAccountID>333333</cbc:SupplierAssignedAccountID> 
    <cac:Party> 
    <cac:PartyName> 
     <cbc:Name>HHW</cbc:Name> 
    </cac:PartyName> 
    <cac:PostalAddress> 
     <cbc:AddressFormatCode>StructuredLax</cbc:AddressFormatCode> 
     <cbc:StreetName>Shuangjing</cbc:StreetName> 
     <cbc:CityName>Beijing</cbc:CityName> 
     <cbc:PostalZone>100020</cbc:PostalZone> 
     <cac:Country> 
     <cbc:IdentificationCode>DK</cbc:IdentificationCode> 
     </cac:Country> 
    </cac:PostalAddress> 
    </cac:Party> 
</cac:AccountingCustomerParty> 
<cac:Delivery> 
    <cac:DeliveryLocation> 
    <cbc:Description>Cheese Factory One</cbc:Description> 
    <cac:Address> 
     <cbc:AddressFormatCode>StructuredLax</cbc:AddressFormatCode> 
     <cbc:StreetName>11 Cheesey Street</cbc:StreetName> 
     <cbc:BuildingNumber></cbc:BuildingNumber> 
     <cbc:CityName>Cheeseville</cbc:CityName> 
     <cbc:PostalZone>11113</cbc:PostalZone> 
     <cac:Country> 
     <cbc:IdentificationCode>DK</cbc:IdentificationCode> 
     </cac:Country> 
    </cac:Address> 
    </cac:DeliveryLocation> 
</cac:Delivery> 
<cac:AnticipatedMonetaryTotal> 
    <cbc:PayableAmount currencyID="DKK">9335.00</cbc:PayableAmount> 
</cac:AnticipatedMonetaryTotal> 
<cac:OrderLine> 
    <cac:LineItem> 
    <cbc:ID>5705154000016</cbc:ID> 
    <cbc:Quantity unitCode="EA">100</cbc:Quantity> 
    <cac:Price> 
     <cbc:PriceAmount currencyID="DKK">93.35</cbc:PriceAmount> 
     <cbc:BaseQuantity unitCode="EA">1</cbc:BaseQuantity> 
    </cac:Price> 
    <cac:Item> 
     <cbc:Description></cbc:Description> 
     <cbc:Name>LYGTE GUL FOR 2D BATTERIER  S</cbc:Name> 
     <cac:BuyersItemIdentification> 
     <cbc:ID schemeName="EAN">5705154000016</cbc:ID> 
     </cac:BuyersItemIdentification> 
     <cac:SellersItemIdentification> 
     <cbc:ID schemeName="EAN">5705154000016</cbc:ID> 
     </cac:SellersItemIdentification> 
    </cac:Item> 
    </cac:LineItem> 
</cac:OrderLine> 
</Order> 

回答

2

縱觀相當大的XSLT文件在http://www.oioubl.info/validator/xslt/OIOUBL_Order_Schematron.xsl,如果你在文本上搜索「中,DocumentType不匹配OIOUBL秩序,不能被驗證這Schematron的」,你會發現它發生在的xsl:否則的代碼

<xsl:choose> 
    <xsl:when test="namespace-uri(*) = 'urn:oasis:names:specification:ubl:schema:xsd:Order-2'"/> 
    <xsl:otherwise> 
     <Error> .... 

此塊與這個特殊的的xsl:選擇在下面的模板匹配發生

<xsl:template mode="M14" match="/" priority="3999"> 

所以,代碼正在的根元素(在這種情況下),並檢查它在命名空間爲「urn:綠洲:名稱:規格:UBL:架構:XSD:訂單2" 。然而,你的XML開始如下...

<Order xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" 
     xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"> 

換句話說,你訂單元素沒有命名空間。

在這種情況下,修復,是添加缺少的命名空間,像這樣

<Order xmlns="urn:oasis:names:specification:ubl:schema:xsd:Order-2" 
     xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" 
     xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"> 

(注意,當你這樣做,你會發現你仍然可以得到其他錯誤在其他地方,但它們都是獨立的問題爲你制定出來!)