-2

请告诉我建议在哪里更正...我尝试了很多,但无法在http://xmlvalidator.new-studio.org/上验证 我的 xml 是

 <?xml version="1.0" standalone="yes"?>
<timeofownership>
<user name="Sana Smith">
<location type="Appartment">
  <articles>
    <pid>AA</pid>
    <product>Laptop</product>
    <OwnFor>30 Days 3 Months 4 Years</OwnFor>
  </articles>
</location>
</user>
<user name="Rooney Mara">
<location type="House">
  <articles>
    <pid>DD</pid>
    <product>iPhone</product>
    <OwnFor>10 Days 4 Months 1 Years</OwnFor>
  </articles>
 </location>
 </user>
 <user name="Rooney Mara">
 <location type="House">
  <articles>
    <pid>TT</pid>
    <product>iPad</product>
    <OwnFor>10 Days 4 Months 0 Years</OwnFor>
  </articles>
  </location>
 </user>
 <user name="Sana Smith">
 <location type="House">
  <articles>
    <pid>BB</pid>
    <product>Desktop</product>
    <OwnFor>5 Days 3 Months 3 Years</OwnFor>
  </articles>
</location>
 </user>
 <user name="Peter Parker">
  <location type="House">
  <articles>
    <pid>CC</pid>
    <product>Fridge</product>
    <OwnFor>30 Days 7 Months 0 Years</OwnFor>
  </articles>
  </location>
  </user>
 <user name="Mia Chu">
  <location type="Appartment">
  <articles>
    <pid>ZZ</pid>
    <product>PS3</product>
    <OwnFor>30 Days 2 Months 0 Years</OwnFor>
   </articles>
  </location>
  </user>
  </timeofownership>

Schema XSD 是——

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
 <xs:element name="timeofownership" >
 <xs:complexType>
  <xs:sequence>
    <xs:element name="user" minOccurs="0" maxOccurs="unbounded">
      <xs:complexType>
        <xs:element name="location">
          <xs:complexType>
            <xs:element name="articles">
              <xs:complexType>
                <xs:sequence>
                  <xs:element name="pid" type="xs:string"/>
                  <xs:element name="product" type="xs:string"/>
                  <xs:element name="OwnFor" type="xs:string"/>
                </xs:sequence>
              </xs:complexType>
            </xs:element>
            <xs:attribute name="type" type="xs.string"/>
          </xs:complexType>
        </xs:element>
        <xs:attribute name="name" type="xs:string"/>
      </xs:complexType>
    </xs:element>
  </xs:sequence>
 </xs:complexType>
 </xs:element>
</xs:schema>

请给我解决这个问题。期待中的感谢。

4

1 回答 1

1

在您对locationanduser节点的定义中,您忘记将元素包装在某种分组节点中。

你不能这样做:

<xs:complexType>
  <xs:element name="foo">
    ...
  </xs:element>
  <xs:attribute name="bar" type="xs:string"/>
<xs:complexType>

你必须把它包起来,在你的情况下可能是xs:all

<xs:complexType>
  <xs:all minOccurs="1">
    <xs:element name="foo">
      ...
    </xs:element>
  </xs:all>
  <xs:attribute name="bar" type="xs:string"/>
</xs:complexType>
于 2013-04-01T20:49:01.590 回答