The command:
xmllint myfile.xml --xpath 'MapField2Data[@country="FR"]/*[@active!="false" or not(@active) ]'
works as expected for my xml structure
But trying to use it in an xsd, it fails to compile:
xmllint --loaddtd --noout --noent --xinclude --schema xsd/pnsConf.xsd pnsConf.xml
xsd/pnsConf.xsd:75: element selector: Schemas parser error : Element '{http://www.w3.org/2001/XMLSchema}selector', attribute 'xpath': The XPath expression 'MapField2Data[@country="FR"]/*[@active!="false" or not(@active) ]' could not be compiled.
My xsd has a proper
<xsd:selector xpath='MapField2Data[@country="FR"]/*[@active!="false" or not(@active) ]'/>
Where a simpler xpath like 'MapField2Data/*' works fine in both situations.
This looks like a bug or a missing feature in xmllint or libxml2.
Should I file a bug on the gnome bugzilla for xmllint?
Maybe there is another solution to my problem in the mean time?
I want "active" tags to be unique and ignore non-active tags in a structure such as this one:
<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>
...
Regards, Emmanuel.
This is not a bug. xsd:selector
only allows a restricted set of XPath operations. Your expression uses predicates which are not allowed. Also see this question.