【发布时间】:2013-03-12 12:27:47
【问题描述】:
我正在尝试在 XSD
中使用以下内容<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" >
<xs:element name="dimension">
<xs:complexType>
<xs:attribute name="height" type="xs:int"/>
<xs:attribute name="width" type="xs:int"/>
<xs:assert test="@height = @width"/>
</xs:complexType>
</xs:element>
我知道断言/断言是 XML Schema 1.1 的一部分,但不是 1.0。然而,我读过的所有内容都表明 namespace 对于两者都是相同的:http://www.w3.org/2001/XMLSchema
一个小问题是我用来编写 Schema (Microsoft Visual Studio) 的程序无法识别“assert”元素,说命名空间中的“元素 complexType (... ) 具有无效的子元素“断言”。
主要问题是,当我实际尝试使用 xmllint 针对此架构验证 XML 时,它会抛出一个错误,说
" element assert: Schemas parser error : Element '{http://www.w3.org/2001/XMLSchema}complexType': The content is not valid. Expected is (annotation?, (simpleContent | complexContent | ((group | all | choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?))))
xmllint/visual studio 根本无法识别 1.1,尽管它被指向 1.1 命名空间?
【问题讨论】:
标签: xml xsd xsd-validation xsd-1.1