我的xml文件如下所示:
<?xml version="1.0" encoding="ISO-8859-1"?>
<Invoice Version="5.0">
</Invoice>
愚蠢:
XSD就像这样开始:
<xsd:schema xmlns="urn:cidx:names:specification:ces:schema:all:5:0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:cidx:names:specification:ces:schema:all:5:0">
我想针对.xsd
验证xml文件我调查了这个,似乎我需要在xml文件中声明.xsd。
所以我试过了:
<Invoice Version="5.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:SchemaLocation="http://www.w3schools.com file:///c:/Users/jpublic/Desktop/CIDX.xsd">
这似乎不起作用......我确信它与声明错误错误有关,但我对xml很新。
我正在尝试通过notepad ++插件XML工具插件2.3.2进行验证 当我单击验证时,它会询问我文件的存在位置,一旦我通过文件打开对话框选择它,它会给我这个错误:
使用XML架构验证当前文件:
错误:元素'发票':没有可用于验证根目录的匹配全局声明。
谢谢!
更新:
好的,所以它允许它现在找到文件,它抱怨不期望的每个元素,即TaxOrDutyTotals':这个元素是不期望的。预计是:
( {urn:cidx:names:specification:ces:schema:all:5:0}TaxOrDuty )
。我认为这意味着它不在.xsd中,但我在这里看到它:
<xsd:element name="TaxOrDutyTotals" type="TaxOrDutyTotalsType"/>
更新2:
的.xsd
?xml version="1.0" encoding="utf-8"?>
<!-- Created with Liquid XML Studio 1.0.8.0 (http://www.liquid-technologies.com) -->
<xsd:schema xmlns="urn:cidx:names:specification:ces:schema:all:5:0" targetNamespace="urn:cidx:names:specification:ces:schema:all:5:0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:simpleType name="cidxBoolean">
<xsd:restriction base="cidxToken">
<xsd:enumeration value="0"/>
<xsd:enumeration value="1"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="cidxDateTime">
<xsd:restriction base="xsd:dateTime"/>
</xsd:simpleType>
<xsd:simpleType name="cidxString">
<xsd:restriction base="xsd:string">
<xsd:minLength value="1"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="cidxToken">
<xsd:restriction base="xsd:token">
<xsd:minLength value="1"/>
<xsd:whiteSpace value="collapse"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="cidxListTaxOrDutyQualifier">
<xsd:restriction base="xsd:NMTOKEN">
<xsd:enumeration value="VAT"/>
<xsd:enumeration value="Duty"/>
<xsd:enumeration value="Fee"/>
<xsd:enumeration value="Tax"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="cidxListTaxOrDutyQualifier">
<xsd:restriction base="xsd:NMTOKEN">
<xsd:enumeration value="VAT"/>
<xsd:enumeration value="Duty"/>
<xsd:enumeration value="Fee"/>
<xsd:enumeration value="Tax"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:element name="Allowances" type="AllowancesType"/>
<xsd:complexType name="AllowancesType">
<xsd:sequence>
<xsd:element ref="AllowanceChargeIndicator"/>
<xsd:element ref="AllowanceChargeType"/>
<xsd:element ref="AllowanceChargeAmount"/>
<xsd:element minOccurs="0" maxOccurs="unbounded" ref="TaxOrDuty"/>
<xsd:element ref="AllowanceChargeCode"/>
<xsd:element ref="AllowanceChargeDescription"/>
<xsd:element minOccurs="0" ref="AllowanceChargeRateInformation"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="InvoiceTotals" type="InvoiceTotalsType"/>
<xsd:complexType name="InvoiceTotalsType">
<xsd:sequence>
<xsd:element minOccurs="0" ref="TotalLineItems"/>
<xsd:element minOccurs="0" ref="LineItemTotalAmount"/>
<xsd:element minOccurs="0" ref="ShippingTotalAmount"/>
<xsd:element minOccurs="0" maxOccurs="unbounded" ref="Allowances"/>
<xsd:element ref="InvoiceTotal"/>
<xsd:element minOccurs="0" maxOccurs="unbounded" ref="TaxOrDutyTotals"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="LineItemTaxableTotal" type="LineItemTaxableTotalType"/>
<xsd:complexType name="LineItemTaxableTotalType">
<xsd:sequence>
<xsd:element ref="MonetaryAmount"/>
<xsd:element minOccurs="0" maxOccurs="unbounded" ref="TaxOrDuty"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="Shipping" type="ShippingType"/>
<xsd:complexType name="ShippingType">
<xsd:sequence>
<xsd:element ref="MonetaryAmount"/>
<xsd:element minOccurs="0" maxOccurs="unbounded" ref="TaxOrDuty"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="TaxLocation" type="TaxLocationType"/>
<xsd:element name="TaxOrDuty" type="TaxOrDutyType"/>
<xsd:complexType name="TaxOrDutyType">
<xsd:sequence>
<xsd:element ref="TaxTypeCode"/>
<xsd:element ref="TaxLocation"/>
<xsd:choice>
<xsd:element ref="Exempt"/>
<xsd:element maxOccurs="unbounded" ref="NonExempt"/>
</xsd:choice>
</xsd:sequence>
<xsd:attribute name="TaxOrDutyQualifier" type="cidxListTaxOrDutyQualifier" use="required"/>
</xsd:complexType>
<xsd:element name="TaxOrDutyTotals" type="TaxOrDutyTotalsType"/>
<xsd:complexType name="TaxOrDutyTotalsType">
<xsd:sequence>
<xsd:element ref="TaxTypeCode"/>
<xsd:element ref="TaxLocation"/>
<xsd:element ref="ExemptTotal"/>
<xsd:element maxOccurs="unbounded" ref="NonExemptTotals"/>
</xsd:sequence>
<xsd:attribute name="TaxOrDutyQualifier" type="cidxListTaxOrDutyQualifier" use="required"/>
</xsd:complexType>
<xsd:element name="TaxRate" type="TaxRateType"/>
<xsd:element name="TaxTypeCode" type="TaxTypeCodeType"/>
<xsd:complexType name="TaxTypeCodeType">
<xsd:simpleContent>
<xsd:extension base="cidxToken">
<xsd:attribute fixed="ANSI-ASC-X12-963" name="Domain" type="cidxToken"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:schema>
.XML
<?xml version="1.0" encoding="ISO-8859-1"?>
<Invoice Version="5.0" xsi:SchemaLocation="file:///c:/Users/someperson/Desktop/CIDX.xsd urn:cidx:names:specification:ces:schema:all:5:0" xmlns = "urn:cidx:names:specification:ces:schema:all:5:0">
<Header>
<ThisDocumentIdentifier>
<DocumentIdentifier>RE12345</DocumentIdentifier>
</ThisDocumentIdentifier>
<ThisDocumentDateTime>
<DateTime DateTimeQualifier="On">2013-10-15T10:00:00Z</DateTime>
</ThisDocumentDateTime>
<From>
<PartnerInformation>
<PartnerName>Partner Gumby</PartnerName>
<PartnerIdentifier Agency="D-U-N-S">123456789</PartnerIdentifier>
</PartnerInformation>
</From>
<To>
<PartnerInformation>
<PartnerName>awesome</PartnerName>
<PartnerIdentifier Agency="D-U-N-S">123456787</PartnerIdentifier>
</PartnerInformation>
</To>
</Header>
<InvoiceBody>
<InvoiceProperties>
<InvoiceNumber>
<DocumentReference>
<DocumentIdentifier>RE12345</DocumentIdentifier>
</DocumentReference>
</InvoiceNumber>
<InvoiceType InvoiceQualifier="Original">Debit</InvoiceType>
<InvoiceDate>
<DateTime DateTimeQualifier="On">2013-04-17T00:00:00Z</DateTime>
</InvoiceDate>
<GrossInvoiceAmount>
<MonetaryAmount>
<MonetaryValue>1186.80</MonetaryValue>
<CurrencyCode Domain="ISO-4217">EUR</CurrencyCode>
</MonetaryAmount>
</GrossInvoiceAmount>
<ReferenceInformation ReferenceType="PurchaseOrderNumber">
<DocumentReference>
<DocumentIdentifier>100000001</DocumentIdentifier>
</DocumentReference>
</ReferenceInformation>
<ReferenceInformation ReferenceType="BookingNumber">
<DocumentReference>
<DocumentIdentifier>E07</DocumentIdentifier>
</DocumentReference>
</ReferenceInformation>
<ReferenceInformation ReferenceType="DeliveryNoteNumber">
<DocumentReference>
<DocumentIdentifier>LS1234</DocumentIdentifier>
<DateTime DateTimeQualifier="On">2013-04-02T00:00:00Z</DateTime>
</DocumentReference>
</ReferenceInformation>
<PrimaryCurrency>
<CurrencyCode Domain="ISO-4217">EUR</CurrencyCode>
</PrimaryCurrency>
<SpecialInstructions InstructionType="CustomerRequiredInstructions">*SupplierTaxNumber:01/234/5678/9</SpecialInstructions>
<SpecialInstructions InstructionType="CustomerRequiredInstructions">*SupplierCommRegNo:132435</SpecialInstructions>
<SpecialInstructions InstructionType="CustomerRequiredInstructions">*SupplierCommCourt:John Q. Public</SpecialInstructions>
<SpecialInstructions InstructionType="CustomerRequiredInstructions">*QSSKZ:QS</SpecialInstructions>
<SpecialInstructions InstructionType="CustomerRequiredInstructions">*TaxCode:AN</SpecialInstructions>
<SpecialInstructions InstructionType="CustomerRequiredInstructions">*ExportSign:1</SpecialInstructions>
<SpecialInstructions InstructionType="CustomerRequiredInstructions">*HeaderText:woot! I</SpecialInstructions>
<SpecialInstructions InstructionType="CustomerRequiredInstructions">*BankCountryKey:US</SpecialInstructions>
<SpecialInstructions InstructionType="CustomerRequiredInstructions">*IBAN:000</SpecialInstructions>
<SpecialInstructions InstructionType="CustomerRequiredInstructions">*SWIFT:bleh</SpecialInstructions>
<InvoiceTotals>
<TotalLineItems>2</TotalLineItems>
<LineItemTotalAmount>
<MonetaryAmount>
<MonetaryValue>1186.80</MonetaryValue>
<CurrencyCode Domain="ISO-4217">EUR</CurrencyCode>
</MonetaryAmount>
</LineItemTotalAmount>
<Allowances>
<AllowanceChargeIndicator>A</AllowanceChargeIndicator>
<AllowanceChargeType>A</AllowanceChargeType>
<AllowanceChargeAmount>
<PricingLumpSum>
<MonetaryAmount>
<MonetaryValue>12.00</MonetaryValue>
<CurrencyCode Domain="ISO-4217">EUR</CurrencyCode>
</MonetaryAmount>
</PricingLumpSum>
</AllowanceChargeAmount>
<AllowanceChargeCode Domain="ANSI-ASC-X12-1300">F050</AllowanceChargeCode>
<AllowanceChargeDescription>some work</AllowanceChargeDescription>
</Allowances>
<Allowances>
<AllowanceChargeIndicator>C</AllowanceChargeIndicator>
<AllowanceChargeType>C</AllowanceChargeType>
<AllowanceChargeAmount>
<PricingLumpSum>
<MonetaryAmount>
<MonetaryValue>12.00</MonetaryValue>
<CurrencyCode Domain="ISO-4217">EUR</CurrencyCode>
</MonetaryAmount>
</PricingLumpSum>
</AllowanceChargeAmount>
<AllowanceChargeCode Domain="ANSI-ASC-X12-1300">F050</AllowanceChargeCode>
<AllowanceChargeDescription>Some Work</AllowanceChargeDescription>
</Allowances>
<Allowances>
<AllowanceChargeIndicator>C</AllowanceChargeIndicator>
<AllowanceChargeType>C</AllowanceChargeType>
<AllowanceChargeAmount>
<PricingLumpSum>
<MonetaryAmount>
<MonetaryValue>0.58</MonetaryValue>
<CurrencyCode Domain="ISO-4217">EUR</CurrencyCode>
</MonetaryAmount>
</PricingLumpSum>
</AllowanceChargeAmount>
<AllowanceChargeCode Domain="ANSI-ASC-X12-1300">D210</AllowanceChargeCode>
<AllowanceChargeDescription>Fun</AllowanceChargeDescription>
</Allowances>
<InvoiceTotal>
<MonetaryAmount>
<MonetaryValue>1326.85</MonetaryValue>
<CurrencyCode Domain="ISO-4217">EUR</CurrencyCode>
</MonetaryAmount>
</InvoiceTotal>
<TaxOrDutyTotals TaxOrDutyQualifier="Tax">
<TaxTypeCode Domain="ANSI-ASC-X12-963">TX</TaxTypeCode>
<TaxLocation>DE</TaxLocation>
<ExemptTotal>
<MonetaryAmount>
<MonetaryValue>0</MonetaryValue>
<CurrencyCode Domain="ISO-4217">EUR</CurrencyCode>
</MonetaryAmount>
</ExemptTotal>
<NonExemptTotals>
<TaxRate>7.00</TaxRate>
<TaxableAmountTotal>
<MonetaryAmount>
<MonetaryValue>712.08</MonetaryValue>
<CurrencyCode Domain="ISO-4217">EUR</CurrencyCode>
</MonetaryAmount>
</TaxableAmountTotal>
<TaxAmountTotal>
<MonetaryAmount>
<MonetaryValue>49.85</MonetaryValue>
<CurrencyCode Domain="ISO-4217">EUR</CurrencyCode>
</MonetaryAmount>
</TaxAmountTotal>
</NonExemptTotals>
<NonExemptTotals>
<TaxRate>19.00</TaxRate>
<TaxableAmountTotal>
<MonetaryAmount>
<MonetaryValue>474.72</MonetaryValue>
<CurrencyCode Domain="ISO-4217">EUR</CurrencyCode>
</MonetaryAmount>
</TaxableAmountTotal>
<TaxAmountTotal>
<MonetaryAmount>
<MonetaryValue>90.20</MonetaryValue>
<CurrencyCode Domain="ISO-4217">EUR</CurrencyCode>
</MonetaryAmount>
</TaxAmountTotal>
</NonExemptTotals>
</TaxOrDutyTotals>
</InvoiceTotals>
<PaymentTerms>
<PaymentTermsOfSale>
<TermsOfSaleDescription>Bis 01.05.2013 </TermsOfSaleDescription>
<NetDaysDue>30</NetDaysDue>
<PaymentDueDate>
<DateTime DateTimeQualifier="On">2013-05-01T00:00:00Z</DateTime>
</PaymentDueDate>
</PaymentTermsOfSale>
<PaymentTermsBasisDate>
<DateTime DateTimeQualifier="On">2013-04-01T00:00:00Z</DateTime>
</PaymentTermsBasisDate>
<Discounts>
<PercentDiscount>3.00</PercentDiscount>
<DaysDue>14</DaysDue>
</Discounts>
</PaymentTerms>
<DeliveryTerms>
<DeliveryTermsCode Domain="Incoterms-2000">abc</DeliveryTermsCode>
<DeliveryTermsLocation>front</DeliveryTermsLocation>
</DeliveryTerms>
</InvoiceProperties>
<InvoicePartners>
<Buyer>
<PartnerInformation>
<PartnerName>banana</PartnerName>
<PartnerName>Accounting</PartnerName>
<PartnerIdentifier Agency="AssignedByBuyer">0050</PartnerIdentifier>
<AddressInformation>
<AddressLine>asdfasf. 38</AddressLine>
<CityName>asdfs</CityName>
<PostalCode>45261</PostalCode>
<PostalCountry>US</PostalCountry>
</AddressInformation>
<TaxInformation>
<TaxIdentifierNumber>DE149145247</TaxIdentifierNumber>
</TaxInformation>
</PartnerInformation>
</Buyer>
<Seller>
<PartnerInformation>
<PartnerName>Name Lieferant</PartnerName>
<PartnerIdentifier Agency="AssignedByBuyer">23456789</PartnerIdentifier>
<AddressInformation>
<AddressLine>Strasse Lieferant</AddressLine>
<CityName>Ort Lieferant</CityName>
<PostalCode>PLZ 12345</PostalCode>
<PostalCountry>DE</PostalCountry>
</AddressInformation>
<TaxInformation>
<TaxIdentifierNumber>DE123456789</TaxIdentifierNumber>
</TaxInformation>
<AccountInformation>
<AccountHolderName>Kontoinhaber</AccountHolderName>
<FinancialInstitutionIdentification>
<FinancialInstitutionName>Name Some Bank</FinancialInstitutionName>
<FinancialInstitutionDFINumber>11111111111</FinancialInstitutionDFINumber>
<AccountNumber>11111111111111111</AccountNumber>
</FinancialInstitutionIdentification>
</AccountInformation>
</PartnerInformation>
</Seller>
<OtherPartner PartnerRole="Receiver">
<PartnerInformation>
<PartnerName>Name banana</PartnerName>
<PartnerIdentifier Agency="AssignedBySeller">000</PartnerIdentifier>
<AddressInformation>
<AddressLine>WE Strasse</AddressLine>
<CityName>WE Ort</CityName>
<PostalCode>68790</PostalCode>
<PostalCountry>DE</PostalCountry>
</AddressInformation>
</PartnerInformation>
</OtherPartner>
<OtherPartner PartnerRole="ShipFrom">
<PartnerInformation>
<PartnerName>ShipFrom</PartnerName>
<PartnerIdentifier Agency="AssignedBySeller">000</PartnerIdentifier>
<AddressInformation>
<CityName>City</CityName>
<PostalCountry>DE</PostalCountry>
</AddressInformation>
</PartnerInformation>
</OtherPartner>
<OtherPartner PartnerRole="ShipTo">
<PartnerInformation>
<PartnerName>ShipTo</PartnerName>
<PartnerIdentifier Agency="AssignedBySeller">000</PartnerIdentifier>
<AddressInformation>
<CityName>City</CityName>
<PostalCountry>GB</PostalCountry>
</AddressInformation>
</PartnerInformation>
</OtherPartner>
</InvoicePartners>
<InvoiceDetails>
<InvoiceLineItem>
<LineNumber>1</LineNumber>
<ProductIdentification>
<ProductIdentifier Agency="AssignedBySeller">12345678</ProductIdentifier>
<ProductDescription>bonanza 1</ProductDescription>
</ProductIdentification>
<ProductQuantity>
<Measurement>
<MeasurementValue>2.000</MeasurementValue>
<UnitOfMeasureCode Domain="UN-Rec-20">PCE</UnitOfMeasureCode>
</Measurement>
</ProductQuantity>
<Pricing PriceType="NetPrice">
<PricingPerUnit>
<MonetaryAmount>
<MonetaryValue>237.36</MonetaryValue>
<CurrencyCode Domain="ISO-4217">EUR</CurrencyCode>
</MonetaryAmount>
<PriceBasis>
<Measurement>
<MeasurementValue>1</MeasurementValue>
<UnitOfMeasureCode Domain="UN-Rec-20">PCE</UnitOfMeasureCode>
</Measurement>
</PriceBasis>
</PricingPerUnit>
</Pricing>
<PurchaseOrderInformation>
<DocumentReference>
<DocumentIdentifier>100000001</DocumentIdentifier>
<ReferenceItem>10</ReferenceItem>
</DocumentReference>
</PurchaseOrderInformation>
<ReferenceInformation ReferenceType="DeliveryNoteNumber">
<DocumentReference>
<DocumentIdentifier>LS1234</DocumentIdentifier>
<DateTime DateTimeQualifier="On">2013-04-02T00:00:00Z</DateTime>
</DocumentReference>
</ReferenceInformation>
<ReferenceInformation ReferenceType="SalesOrderReference">
<DocumentReference>
<DocumentIdentifier>2013000002</DocumentIdentifier>
<ReferenceItem>30</ReferenceItem>
</DocumentReference>
</ReferenceInformation>
<OtherPartner PartnerRole="ShipFrom">
<PartnerInformation>
<PartnerName>ShipFrom</PartnerName>
<PartnerIdentifier Agency="AssignedBySeller">000</PartnerIdentifier>
<AddressInformation>
<CityName>City</CityName>
<PostalCountry>US</PostalCountry>
</AddressInformation>
</PartnerInformation>
</OtherPartner>
<OtherPartner PartnerRole="ShipTo">
<PartnerInformation>
<PartnerName>ShipTo</PartnerName>
<PartnerIdentifier Agency="AssignedByBuyer">1630</PartnerIdentifier>
<AddressInformation>
<CityName>City</CityName>
<PostalCountry>US</PostalCountry>
</AddressInformation>
</PartnerInformation>
</OtherPartner>
<SpecialInstructions InstructionType="CustomerRequiredInstructions">*TXJCD:NY</SpecialInstructions>
<SpecialInstructions InstructionType="CustomerRequiredInstructions">*TaxCode:AN</SpecialInstructions>
<LineItemTaxableTotal>
<MonetaryAmount>
<MonetaryValue>474.72</MonetaryValue>
<CurrencyCode Domain="ISO-4217">EUR</CurrencyCode>
</MonetaryAmount>
<TaxOrDuty TaxOrDutyQualifier="Tax">
<TaxTypeCode Domain="ANSI-ASC-X12-963">TX</TaxTypeCode>
<TaxLocation>US</TaxLocation>
<NonExempt>
<TaxRate>19.00</TaxRate>
<TaxableAmount>
<MonetaryAmount>
<MonetaryValue>474.72</MonetaryValue>
<CurrencyCode Domain="ISO-4217">EUR</CurrencyCode>
</MonetaryAmount>
</TaxableAmount>
<TaxAmount>
<MonetaryAmount>
<MonetaryValue>90.20</MonetaryValue>
<CurrencyCode Domain="ISO-4217">EUR</CurrencyCode>
</MonetaryAmount>
</TaxAmount>
</NonExempt>
</TaxOrDuty>
</LineItemTaxableTotal>
</InvoiceLineItem>
</InvoiceDetails>
</InvoiceBody>
好吧,试试吧。
答案 0 :(得分:0)
尝试以下方法:
<Invoice Version="5.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:SchemaLocation="file:///c:/Users/jpublic/Desktop/CIDX.xsd urn:cidx:names:specification:ces:schema:all:5:0" xmlns = "urn:cidx:names:specification:ces:schema:all:5:0">
//....
</Invoice>
答案 1 :(得分:0)
这个XSD错了。它有很多错误。
这部分重复......
<xsd:simpleType name="cidxListTaxOrDutyQualifier">
<xsd:restriction base="xsd:NMTOKEN">
<xsd:enumeration value="VAT"/>
<xsd:enumeration value="Duty"/>
<xsd:enumeration value="Fee"/>
<xsd:enumeration value="Tax"/>
</xsd:restriction>
</xsd:simpleType>
没有TaxLocationType和TaxRateType
<xsd:element name="TaxLocation" type="TaxLocationType" />
<xsd:element name="TaxRate" type="TaxRateType" />
参考物品在哪里......?
<xsd:element ref="AllowanceChargeIndicator"/>
<xsd:element ref="AllowanceChargeType"/>
<xsd:element ref="AllowanceChargeAmount"/>
我认为如果你写一个正确的xsd它会起作用。欢呼声