在 XML 中出现多次(例如 2 次)的元素的架构总是失败,并给出错误“架构有效性错误:元素 '名称':此元素不是预期的”。“名称”是 XML 文件的中间元素,即我们在 XML 中有其他元素,而“名称”位于 XML 文件的中间。XML 文件具有正确的标题为“”
Sample "name" element in XML file :
<name>
<First>1</First>
<last>1</last>
</name>
<name>
<First>1</First>
<last>1</last>
</name>
Sample Schema tried as below, but nothing works. However after commenting the second instance of "name" in XML, schema is validated successfully. PLEASE HELP.
<xs:element name="name" >
<xs:complexType mixed="true">
<xs:sequence>
<xs:element ref="First"/>
<xs:element ref="last"/>
<xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="name" >
<xs:complexType mixed="true">
<xs:sequence minOccurs="1" maxOccurs="3">
<xs:element ref="First"/>
<xs:element ref="last"/>
<xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="name" >
<xs:complexType mixed="true">
<xs:all>
<xs:element ref="First"/>
<xs:element ref="last"/>
<xs:all>
</xs:complexType>
</xs:element>
<xs:element name="name" minOccurs="1" maxOccurs="3" >
<xs:complexType mixed="true">
<xs:sequence >
<xs:element ref="First"/>
<xs:element ref="last"/>
<xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="name">
<xs:complexType mixed="true">
<xs:choice maxOccurs="3" >
<xs:element ref="First"/>
<xs:element ref="last"/>
<xs:choice>
</xs:complexType>
</xs:element>