代码之家  ›  专栏  ›  技术社区  ›  Emmanuel Courreges

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

  •  0
  • Emmanuel Courreges  · 技术社区  · 11 年前

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

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

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

    我的xsd有一个适当的

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

    其中,像“MapField2Data/*”这样的简单xpath在这两种情况下都很好。
    这看起来像是xmllint或libxml2中的一个bug或缺失的功能。
    我应该为xmllint在gnome bugzilla上提交bug吗?

    也许有 我问题的另一个解决方案 同时?
    我希望“活动”标记是唯一的,并忽略像这样的结构中的非活动标记:

    <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 回复  |  直到 11 年前
        1
  •  1
  •   Community CDub    7 年前

    这不是一个bug。 xsd:selector 仅允许 restricted set of XPath operations 。您的表达式使用了不允许的谓词。另请参见 this question .