我正在使用Ant的schemavalidate任务来验证XML文档。
<schemavalidate
noNamespaceFile="${user.input.xsd}" file="${user.input.xml}">
</schemavalidate>这如预期的那样起作用。但是现在我有了使用XInclude的模式文件,如下所示:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="..." xpointer="xmlns(xs=http://www.w3.org/2001/XMLSchema)xpointer(/xs:schema/xs:*)"/>
</xs:schema>这在Ant中产生了以下错误:
foo.xsd:8:136: s4s-elt-schema-ns:元素'include‘的命名空间必须来自模式名称空间'http://www.w3.org/2001/XMLSchema’。
现在,我尝试通过启用相应的特性来启用XInclude处理:
<schemavalidate
noNamespaceFile="${user.input.xsd}" file="${user.input.xml}">
<attribute name="http://apache.org/xml/features/xinclude" value="true"/>
</schemavalidate>但这没有帮助,错误信息保持不变。该特性似乎被解析器识别,因为当我将属性元素更改为使用一些不存在的特性时,我会得到相应的错误消息。
解析器org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser不识别特性http://apache.org/xml/features/xinclud
这里可以启用XInclude处理吗?
编辑1
在启用Ant调试模式时,我可以看到正确设置了该特性:
[schemavalidate] Using SAX2 reader org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser
[schemavalidate] Setting feature http://xml.org/sax/features/validation=true
[schemavalidate] Setting feature http://apache.org/xml/features/xinclude=true
[schemavalidate] Setting feature http://xml.org/sax/features/namespaces=true
[schemavalidate] Setting feature http://apache.org/xml/features/validation/schema=true
[schemavalidate] Setting feature http://apache.org/xml/features/validation/schema-full-checking=true
[schemavalidate] Validating foo.xml...发布于 2022-04-17 17:22:27
你的计划任务是正确的。这似乎是过去的一个错误。我可以说它适用于蚂蚁1.10.9。不知道什么时候修好。
https://stackoverflow.com/questions/37411469
复制相似问题