xmllint xsd:选择器xpath行为与--xpath或--shell不同

时间:2014-02-13 17:42:32

标签: xpath xsd libxml2 xmllint

命令:
xmllint myfile.xml --xpath'MapField2Data [@ country =“FR”] / * [@ active!=“false”或不(@active)]'
我的xml结构按预期工作

但是试图在xsd中使用它,它无法编译:

xmllint --loaddtd --noout --noent --xinclude - 架构 xsd / pnsConf.xsd pnsConf.xml
xsd / pnsConf.xsd:75:元素选择器:模式解析器错误:元素'{http://www.w3.org/2001/XMLSchema}选择器',属性'xpath': XPath表达式'MapField2Data [@ country =“FR”] / * [@active!=“false”或不(@active)]'无法编译

我的xsd有一个合适的

<xsd:selector xpath='MapField2Data[@country="FR"]/*[@active!="false" or not(@active) ]'/>

在这两种情况下,像'MapField2Data / *'这样的简单xpath工作正常 这看起来像xmllint或libxml2中的错误或缺少的功能 我应该在xnllint的gnome bugzilla上提交错误吗?

同时可能我的问题的另一个解决方案
我希望“活动”标记是唯一的,并忽略结构中的非活动标记,例如:

<MapField2Data country='FR' >
    <raw id='NoUnReadMails' active='true'>
            <depend ref='_EndMailNotif'/>
            <depend ref='_EndMailSub' />
    </raw>
    <raw id='NoUnReadMails' active='false'>
            <depend ref='_EndMailNotif'/>
            <depend ref='_EndMailSub' />
    </raw>
    <raw id='NoEMails' >
            <depend ref='_EndMailNotif'/>
            <depend ref='_EndMailSub' />
    </raw>
...

此致 灵光。

1 个答案:

答案 0 :(得分:1)

这不是错误。 xsd:selector仅允许restricted set of XPath operations。您的表达式使用不允许的谓词。另请参阅this question