尝试验证 xml 架构时出现以下错误-
16: 24 s4s-elt-must-match.1: The content of 'member' must match (annotation?, (simpleType | complexType)?, (unique | key | keyref)*)). A problem was found starting at: complextype.
31: 21 s4s-elt-must-match.1: The content of 'intake' must match (annotation?, (simpleType | complexType)?, (unique | key | keyref)*)). A problem was found starting at: complextype.
下面是架构-
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.w3schools.com"
xmlns="http://www.w3schools.com"
elementFormDefault="qualified">
<xs:element name="record">
<xs:complexType>
<xs:sequence>
<xs:element name="id" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="hof" type="xs:string" minOccurs="1" maxOccurs="1"/>
<xs:element name="member" minOccurs="1" maxOccurs="unbounded">
<xs:complextype>
<xs:all>
<xs:element name="name" type="xs:string"/>
<xs:element name="age" type="xs:nonNegativeInteger"/>
<xs:element name="sex" type="xs:string"/>
<xs:element name="occupation" type="xs:string" minOccurs="0"/>
<xs:element name="pregnant" type="xs:boolean" minOccurs="0"/>
<xs:element name="lactating" type="xs:boolean" minOccurs="0"/>
</xs:all>
</xs:complextype>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="intake" minOccurs="1" maxOccurs="1">
<xs:complextype>
<xs:sequence>
<xs:element name="food" minOccurs="0" maxOccurs="unbounded">
<xs:complextype>
<xs:sequence>
<xs:element name="name" type="xs:string" minOccurs="1" maxOccurs="1"/>
<xs:element name="amount" type="xs:decimal" minInclusive="0" minOccurs="1" maxOccurs="1"/>
</xs:sequence>
</xs:complextype>
</xs:element>
</xs:sequence>
</xs:complextype>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
这是相应的 XML 文件-
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<record xmlns="http://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3schools.com record.xsd">
<id>
<hof>ABC</hof>
<member>
<name>ABC</name>
<age>35</age>
<sex>Male</sex>
<occupation>Manual Laboror</occupation>
</member>
<member>
<name>DEF</name>
<age>30</age>
<sex>Female</sex>
<occupation>House Wife</occupation>
<pregnant>no</pregnant>
<lactating>no</lactating>
</member>
<member>
<name>ghi</name>
<age>2</age>
<sex>Female</sex>
</member>
</id>
<intake>
<food>
<name>rice</name>
<amount>800</amount>
</food>
<food>
<name>dal</name>
<amount>200</amount>
</food>
</intake>
</record>
我已经尝试过此处提供的解决方案,但无法正常工作。