XML Schema 1.1无法识别'assert'或'assertion'

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了XML Schema 1.1无法识别'assert'或'assertion'相关的知识,希望对你有一定的参考价值。

我试图在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>

我知道assert / assertion是XML Schema 1.1的一部分,但不是1.0。但是我读过的所有内容都表明命名空间对于两者都是相同的:http://www.w3.org/2001/XMLSchema

一个小问题是我用来编写Schema(Microsoft Visual Studio)的程序无法识别'assert'元素,说'命名空间中的元素complexType(...)具有无效的子元素'assert'。

主要的问题是,当我实际尝试使用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?))))

虽然被指向了1.1名称空间,但xmllint / visual studio却无法识别1.1吗?

答案

要处理XSD 1.1架构,您需要一个XSD 1.1架构处理器。微软没有提供(他们似乎放弃了实施新的W3C XML规范)。据我所知,.NET平台上唯一可用的XSD 1.1处理器是Saxonica。

以上是关于XML Schema 1.1无法识别'assert'或'assertion'的主要内容,如果未能解决你的问题,请参考以下文章

IntelliJ中无法识别XML Schema唯一约束

在 DisplayObjectContainer 中识别 AS3 中的 MovieClip

JavaScripts学习日记——XML DTD Schema

xml文件不识别dubbo标签,添加支持的方法

org.xml.sax.SAXNotRecognizedException:无法识别功能“http://javax.xml.XMLConstants/feature/secure-processing

通配符的匹配很全面, 但无法找到元素 'xxxxxxxx'