我如何编写一个可以验证以下两个XML文档的XSD?
<Credits>
<Actor>Jules Verne</Actor>
<Director>Movie</Director>
</Credits>
<xs:element name="Credits">
<xs:complexType>
<xs:choice>
<xs:sequence>
<xs:element name="Director" type="xs:string" minOccurs="0" maxOccurs="3" />
<xs:element name="Producer" type="xs:string" minOccurs="0" maxOccurs="3" />
<xs:element name="Actor" type="xs:string" minOccurs="0" maxOccurs="3" />
<xs:element name="Writer" type="xs:string" minOccurs="0" maxOccurs="3" />
</xs:sequence>
</xs:choice>
</xs:complexType>
</xs:element>
到目前为止,这是我所拥有的,但这并不允许我上面的无序选项:
set digraph
我怎么会有多个重复元素,没有特定的顺序?
答案 0 :(得分:2)
以下XSD将验证两个XML文档:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Credits">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Director" type="xs:string" />
<xs:element name="Producer" type="xs:string" />
<xs:element name="Actor" type="xs:string" />
<xs:element name="Writer" type="xs:string" />
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>