xmllint无法解析具有属性的schematron

xmllint无法解析具有属性的schematron,xml,xmllint,schematron,Xml,Xmllint,Schematron,当我尝试使用xmllint对schematron进行验证时,收到一个错误 我希望测试用特定属性标记的XML元素。因此,使用 关于如何实现这一点,有什么建议吗?如果您将上下文表达式更改为仅人,它会起作用。这就是问题所在。如何在属性上应用过滤器?为什么需要?据我所知,这条规则在Person上的效果与预期的一样,因为schematron的例子说明了这一点。在我的现实世界中,我处理的记录不止一条,而且它们因属性不同而不同。 <Person Title="Mr"> <Name&g

当我尝试使用xmllint对schematron进行验证时,收到一个错误

我希望测试用特定属性标记的XML元素。因此,使用


关于如何实现这一点,有什么建议吗?

如果您将
上下文
表达式更改为仅
,它会起作用。这就是问题所在。如何在属性上应用过滤器?为什么需要?据我所知,这条规则在
Person
上的效果与预期的一样,因为schematron的例子说明了这一点。在我的现实世界中,我处理的记录不止一条,而且它们因属性不同而不同。
<Person Title="Mr">
    <Name>Eddie</Name>
    <Gender>Male</Gender>
</Person>
<?xml version="1.0" encoding="UTF-8"?>
<sch:schema xmlns:sch="http://www.ascc.net/xml/schematron">
    <sch:pattern name="Check co-occurrence constraints">
        <sch:rule context="Person[@Title='Mr']">
            <sch:assert test="(@Title = 'Mr' and Gender = 'Male') or @Title != 'Mr'">If the Title is "Mr" then the gender of the person must be "Male".</sch:assert>
        </sch:rule>
    </sch:pattern>
</sch:schema>
$ xmllint --schematron sample-schematron.schema.xml sample-schematron.xml
sample-schematron.schema.xml:11: element rule: Schemas parser error : Failed to compile context expression Person[@Title='Mr']
Schematron schema sample-schematron.schema.xml failed to compile

$ xmllint --version
xmllint: using libxml version 20706
   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