Xml cvc elt.1.a:找不到元素';订单';

Xml cvc elt.1.a:找不到元素';订单';,xml,xsd,Xml,Xsd,我知道错误的含义,但就我所见,Order元素在模式中正确声明。这与我声明模式位置的方式有关吗?我不知道如何着手修改申报单。有什么想法吗 我的XML <?xml version="1.0" encoding="ISO-8859-1"?> <Order xmlns="http://www.w3schools.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://l

我知道错误的含义,但就我所见,Order元素在模式中正确声明。这与我声明模式位置的方式有关吗?我不知道如何着手修改申报单。有什么想法吗

我的XML

<?xml version="1.0" encoding="ISO-8859-1"?>
<Order 
xmlns="http://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://lolteamrecruiter.com order.xsd">
  <Customer id="n12">Aaron Rodgers</Customer>
  <Product>
    <Name>Old Time Souvenir Football</Name>
    <SKU>244</SKU>
    <Quantity>12</Quantity>
    <Price currency="taco">21.95</Price>
    <ShipTo>
      <Street>135 Airline Highway</Street>
      <City>Green Bay</City> <State>WI</State> <Zip>02882</Zip>
    </ShipTo>
  </Product>
  <Product>
    <Name>Official Packer Football</Name>
    <SKU>256</SKU>
    <Quantity>1</Quantity>
    <Price currency="USD">France</Price>
    <Discount>.10</Discount>
    <ShipTo>
      <GiftRecipient>Gertrude Rodgers</GiftRecipient>
      <Street>271 Old Homestead Way</Street>
      <City>San Francisco</City> <State>CA</State> <Zip>02895</Zip>
    </ShipTo>
    <GiftMessage>Happy Mothers Day to a great Mom! Love, Aaron</GiftMessage>
  </Product> 
  <Subtotal currency='USD'>263.40</Subtotal>
  <Tax rate="7.0" 
       currency='USD'>18.44</Tax>
  <Shipping  method="USPS" currency='USD'>8.95</Shipping>
  <Total currency='USD' >290.79</Total>
</Order>

包装工
旧时足球纪念品
244
12
21.95
135航空公路
青湾WI 02882
官方打包机足球
256
1.
法国
.10
格特鲁德·罗杰斯
271老宅地路
旧金山CA 02895
祝伟大的妈妈母亲节快乐!爱你的,亚伦
263.40
18.44
8.95
290.79
我的XSD

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">

<xs:element name="Order">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="Customer" type="xs:string">
        <xs:complexType>
            <xs:attribute name="id" type="xs:string"  use="required"/>
        </xs:complexType>
      </xs:element>
      <xs:element name="Product" minOccurs="1" maxOccurs="unbounded">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="Name" type="xs:string"/>
                <xs:element name="SKU" type="xs:string"/>
                <xs:element name="Quantity" type="xs:string"/>
                <xs:element name="Price" type="currRestrict">
                    <xs:complexType>
                        <xs:attribute name="currency" type="currencyType" use="required"/>
                    </xs:complexType>               
                </xs:element>
                <xs:element name="Discount" type="xs:string" minOccurs="0" maxOccurs="1"/>
                <xs:element name="ShipTo">
                      <xs:complexType>
                        <xs:sequence>
                            <xs:element name="GiftRecipient" type="xs:string"/>
                            <xs:element name="street" type="xs:string"/>
                            <xs:element name="City" type="xs:string"/>
                            <xs:element name="State" type="xs:decimal"/>
                            <xs:element name="Zip" type="xs:decimal"/>
                        </xs:sequence>
                      </xs:complexType>
                </xs:element>
                <xs:element name="GiftMessage" type="xs:string" minOccurs="0" maxOccurs="1"/>
            </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="Subtotal" type="xs:decimal">
        <xs:complexType>
            <xs:attribute name="currency" type="currencyType" use="required"/>
        </xs:complexType>               
      </xs:element>
       <xs:element name="Tax" type="xs:decimal">
        <xs:complexType>
            <xs:attribute name="currency" type="currencyType" use="required"/>
            <xs:attribute name="rate" type="currencyType"/>
        </xs:complexType>               
      </xs:element>
       <xs:element name="Shipping" type="xs:string">
        <xs:complexType>
            <xs:attribute name="currency" type="currencyType" use="required"/>
            <xs:attribute name="method" type="methodType" default="UPS"/>
        </xs:complexType>               
      </xs:element>
      <xs:element name="Total" type="xs:decimal">
        <xs:complexType>
            <xs:attribute name="currency" type="currencyType" use="required"/>
        </xs:complexType>               
      </xs:element>
    </xs:sequence>
  </xs:complexType>
</xs:element>

<xs:simpleType name="currencyType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="USD"/>
      <xs:enumeration value="CAN"/>
      <xs:enumeration value="GBP"/>
    </xs:restriction>
</xs:simpleType>

<xs:simpleType name="methodType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="UPS"/>
      <xs:enumeration value="USPS"/>
      <xs:enumeration value="Overnight"/>
    </xs:restriction>
</xs:simpleType>

<xs:simpleType name="currRestrict">
    <xs:restriction base="xs:decimal">
    </xs:restriction>
</xs:simpleType>

</xs:schema>

您的实例文档具有
xmlns=”http://www.w3schools.com“
但是您的架构没有targetNamespace。因此,模式在没有命名空间的情况下给出名为
Order
的元素声明,但验证器在
http://www.w3schools.com
名称空间

添加
targetNamespace=”http://www.w3schools.com“
xs:schema
开始标记,并修复
xsi:schemaLocation
以匹配-它当前使用了错误的命名空间URI

xsi:schemaLocation="http://www.w3schools.com order.xsd"

实例文档的名称空间、架构的targetNamespace以及使用
xsi:schemaLocation
映射到架构的名称空间都必须相同。

删除xmlns=“”不能解决此问题。除非我误解了你的意思。将targetNamespace添加到开始标记中仍然不起作用。@user2789380我一眼就忽略了schemaLocation映射-这也需要修复。的可能重复项