请告诉我建议在哪里纠正...... 我尝试了很多,但无法在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>
请给我这个问题。 感谢期待。
答案 0 :(得分:1)
在location
和user
节点的定义中,您忘记将元素包装在某种分组节点中。
你做不到:
<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>