我试图验证以下XML:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:dc="http://dublincore.org/schemas/xmls/qdc/2008/02/11/dc.xsd">
<xs:element name="feature">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:annotation>
<xs:documentation xml:lang="de-x-mt">
<dc:title xml:lang="de-x-mt">Berg</dc:title>
<dc:title xml:lang="en-x-mt">Mountain</dc:title>
</xs:documentation>
</xs:annotation>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:schema>使用以下xmllint
xmllint: using libxml version 20901
compiled with: Threads Tree Output Push Reader Patterns Writer SAXv1 FTP HTTP DTDValid HTML Legacy C14N Catalog XPath XPointer XInclude Iconv ISO8859X Unicode Regexps Automata Expr Schemas Schematron Modules Debug Zlib Lzmaxmllint说:
test.xsd:7: element documentation: Schemas parser error : Element '{http://www.w3.org/2001/XMLSchema}documentation', attribute '{http://www.w3.org/XML/1998/namespace}lang': 'de-x-mt' is not a valid value of the atomic type 'xs:language'.
WXS schema test.xsd failed to compile我无法理解为什么在xs:documentation元素中“de”不是有效的"xs:language“,而dc:title元素中相同的”de“则是有效的。它们都来自xml命名空间,应该以相同的方式对待它们。它实际上是相同的属性!是吗?!
根据"W3C XML定义语言(XSD) 1.1第2部分:数据类型“xs:语言定义为:
符合模式的所有字符串的集合。 A-zA{1,8}(-a-Za-Z0-9{1,8})*
很明显de与这个模式相匹配。
是xmllint错误吗?如何获得xmllint来验证这样的xs:语言标记?
发布于 2015-05-23 16:14:08
我在parser.c注释中找到了libxml2 (xmllint使用的)函数xmlCheckLanguageID():
The parser below doesn't try to cope with extension or privateuse
that could be added but that's not interoperable anyway下面是一个代码:
if (nxt - cur == 4)
goto script;
if (nxt - cur == 2)
goto region;
if ((nxt - cur >= 5) && (nxt - cur <= 8))
goto variant;
if (nxt - cur != 3)
return(0);如你所见,单身人士没有免税额。基本上,libxml2 2的xmlCheckLanguageID在扩展或私用单例方面不符合标准。
要纠正这个问题,我们需要有以下代码:
if (nxt - cur == 1)
goto extension;下面是:
/* extensions and private use subtags not checked */
extensions:
return (1);我已经在bug.cgi?id=749763上提交了错误报告
https://stackoverflow.com/questions/29314958
复制相似问题