1
我想驗證以下XML,而不強加點的順序:XSD和xmllint:更換XS:與XS順序:所有的給出錯誤
<?xml version='1.0' encoding='ISO-8859-1'?>
<root>
<name>Map corners</name>
<point>NW</point>
<point>SW</point>
<point>NE</point>
<point>SE</point>
</root>
我的XSD是:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="point" type="xs:string" fixed="NW"/>
<xs:element name="point" type="xs:string" fixed="SW"/>
<xs:element name="point" type="xs:string" fixed="NE"/>
<xs:element name="point" type="xs:string" fixed="SE"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
xmllint驗證我的XML。
但是,如果我取代的xs:與XS序列:所有(下達訂單約束:SW可以NW)之前,它不驗證,我有以下消息:
my6.xsd: 4:元素complexType:模式解析器錯誤:本地複雜類型:內容模型不是確定性的。
我錯過了什麼嗎?
謝謝Petru。添加身份約束有助於避免例如NW,NW,NW,SE。這意味着:「此(。)」點「必須是唯一的」(使用xs:key和xs:unique幾乎相同)。另見:http://docstore.mik.ua/orelly/xml/schema/ch09_02.htm – 2015-03-23 12:17:08