Error: The content of 'persons' must match (annotation?, (simpleType | complexType)?, (unique | key | keyref)*))
Error: The content of 'persons' must match (annotation?, (simpleType | complexType)?, (unique | key | keyref)*))
我正在尝试为 XML 输入 XSD,但发生错误。我不知道为什么会这样。我是 XML 的新手,所以不太了解它。
错误是:
Exception: s4s-elt-must-match.1: The content of 'persons' must match
(annotation?, (simpleType | complexType)?, (unique | key | keyref)*)).
A problem was found starting at: complexType.
非常感谢任何帮助或建议。
XML
<?xml version="1.0" encoding="utf-8"?>
<persons>
<person>
<name>Tom</name>
<age>11</age>
<gender>M</gender>
<address>
<doorno>27</doorno>
<street>Tony's road, koramangala</street>
<city>Bangalore</city>
<state>Karnataka</state>
</address>
<student>
<rollno>10</rollno>
<standard>6</standard>
<section>A</section>
</student>
</person>
<person>
<name>Shiny</name>
<age>12</age>
<gender>F</gender>
<address>
<doorno>10</doorno>
<street>Main Bazar, Madiwala</street>
<city>Bangalore</city>
<state>Karnataka</state>
</address>
<staff>
<staffid>123</staffid>
<subject>Maths</subject>
</staff>
</person>
</persons>
XSD 我正在尝试写
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="persons">
<xs:complexType>
<xs:sequence>
<xs:element name="person" maxOccurs="unbounded" minOccurs="1" type="personType"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="personType">
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="age" type="xs:integer"/>
<xs:element name="gender" type="xs:string"/>
<xs:element name="address" type="addType"/>
<xs:element name="student" maxOccurs="unbounded" minOccurs="0" type="studentType"/>
<xs:element name="staff" maxOccurs="unbounded" minOccurs="0" type="staffType"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="addType">
<xs:sequence>
<xs:element name="doorno" type="xs:integer"/>
<xs:element name="street" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
<xs:element name="state" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="studentType">
<xs:sequence>
<xs:element name="rollno" type="xs:integer"/>
<xs:element name="standard" type="xs:string"/>
<xs:element name="section" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="staffType">
<xs:sequence>
<xs:element name="staffid" type="xs:integer"/>
<xs:element name="stubject" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
需要两个修复:
- 在复杂类型前关闭
person
的 xs:element
标签
其余类型的声明。
- 修正一个错字:
stubject
应该是 `subjection.
总而言之,以下 XSD 将成功验证您的 XML 文档:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="persons">
<xs:complexType>
<xs:sequence>
<xs:element name="person" maxOccurs="unbounded" minOccurs="1" type="personType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="personType">
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="age" type="xs:integer"/>
<xs:element name="gender" type="xs:string"/>
<xs:element name="address" type="addType"/>
<xs:element name="student" maxOccurs="unbounded" minOccurs="0" type="studentType"/>
<xs:element name="staff" maxOccurs="unbounded" minOccurs="0" type="staffType"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="addType">
<xs:sequence>
<xs:element name="doorno" type="xs:integer"/>
<xs:element name="street" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
<xs:element name="state" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="studentType">
<xs:sequence>
<xs:element name="rollno" type="xs:integer"/>
<xs:element name="standard" type="xs:string"/>
<xs:element name="section" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="staffType">
<xs:sequence>
<xs:element name="staffid" type="xs:integer"/>
<xs:element name="subject" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
我正在尝试为 XML 输入 XSD,但发生错误。我不知道为什么会这样。我是 XML 的新手,所以不太了解它。 错误是:
Exception: s4s-elt-must-match.1: The content of 'persons' must match (annotation?, (simpleType | complexType)?, (unique | key | keyref)*)). A problem was found starting at: complexType.
非常感谢任何帮助或建议。
XML
<?xml version="1.0" encoding="utf-8"?>
<persons>
<person>
<name>Tom</name>
<age>11</age>
<gender>M</gender>
<address>
<doorno>27</doorno>
<street>Tony's road, koramangala</street>
<city>Bangalore</city>
<state>Karnataka</state>
</address>
<student>
<rollno>10</rollno>
<standard>6</standard>
<section>A</section>
</student>
</person>
<person>
<name>Shiny</name>
<age>12</age>
<gender>F</gender>
<address>
<doorno>10</doorno>
<street>Main Bazar, Madiwala</street>
<city>Bangalore</city>
<state>Karnataka</state>
</address>
<staff>
<staffid>123</staffid>
<subject>Maths</subject>
</staff>
</person>
</persons>
XSD 我正在尝试写
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="persons">
<xs:complexType>
<xs:sequence>
<xs:element name="person" maxOccurs="unbounded" minOccurs="1" type="personType"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="personType">
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="age" type="xs:integer"/>
<xs:element name="gender" type="xs:string"/>
<xs:element name="address" type="addType"/>
<xs:element name="student" maxOccurs="unbounded" minOccurs="0" type="studentType"/>
<xs:element name="staff" maxOccurs="unbounded" minOccurs="0" type="staffType"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="addType">
<xs:sequence>
<xs:element name="doorno" type="xs:integer"/>
<xs:element name="street" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
<xs:element name="state" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="studentType">
<xs:sequence>
<xs:element name="rollno" type="xs:integer"/>
<xs:element name="standard" type="xs:string"/>
<xs:element name="section" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="staffType">
<xs:sequence>
<xs:element name="staffid" type="xs:integer"/>
<xs:element name="stubject" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
需要两个修复:
- 在复杂类型前关闭
person
的xs:element
标签 其余类型的声明。 - 修正一个错字:
stubject
应该是 `subjection.
总而言之,以下 XSD 将成功验证您的 XML 文档:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="persons">
<xs:complexType>
<xs:sequence>
<xs:element name="person" maxOccurs="unbounded" minOccurs="1" type="personType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="personType">
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="age" type="xs:integer"/>
<xs:element name="gender" type="xs:string"/>
<xs:element name="address" type="addType"/>
<xs:element name="student" maxOccurs="unbounded" minOccurs="0" type="studentType"/>
<xs:element name="staff" maxOccurs="unbounded" minOccurs="0" type="staffType"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="addType">
<xs:sequence>
<xs:element name="doorno" type="xs:integer"/>
<xs:element name="street" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
<xs:element name="state" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="studentType">
<xs:sequence>
<xs:element name="rollno" type="xs:integer"/>
<xs:element name="standard" type="xs:string"/>
<xs:element name="section" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="staffType">
<xs:sequence>
<xs:element name="staffid" type="xs:integer"/>
<xs:element name="subject" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>