2013-03-22 58 views
10

我试图使用一个XSDXML架构1.1,不承认“断言”或“断言”

<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架构1.1的一部分,但不是1.0。不过,我已经读到的一切表示命名空间是上是相同的:http://www.w3.org/2001/XMLSchema

一个小问题是,我使用写模式(微软的Visual Studio)不承认“断言”元素的节目,说名称空间(...)中的元素complexType具有无效的子元素“assert”。

的主要问题是,当我真正尝试验证XML根据该模式,使用xmllint,它抛出了一个错误,说

" 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?)))) 

为1.1根本就不是由xmllint/Visual Studio的认可,尽管是指向1.1命名空间?

回答

16

要处理XSD 1.1模式,您需要XSD 1.1模式处理器。微软不提供一个(他们似乎已经放弃实施新的W3C XML规范)。据我所知,.NET平台上唯一可用的XSD 1.1处理器是Saxonica's。

+0

谢谢!我是xml架构的新手,但会想到处理器只会从您指向的名称空间中提取最新的定义。 是否有任何适用于Linux的1.1 XSD兼容编辑器? – user2197116 2013-03-25 17:33:59

+0

不,您不能指望在1994年开发的处理器实现2013年发布的规范。oXygen是一个在Linux上运行并支持XSD 1.1的编辑器 – 2013-03-26 18:23:54