I have the following xmls:
sample1.xml
<root>
<subjectInfo>
<subject id="001"/>
<subject id="002" role="cross"/>
</subjectInfo>
</root>
sample2.xml
<root>
<subjectInfo>
<subject id="002"/>
<subject id="001" role="cross"/>
</subjectInfo>
</root>
I am searching for the documents where value of id
attribute of subject
is "001" but role
(if it's there) of the same subject
element is not "cross".So, In my example the result should contain sample1.xml
and not sample2.xml
I thought the following query would do the job:
<code>
cts:search(/root,
cts:near-query((
cts:element-attribute-value-query(xs:QName("subject"),xs:QName("id"),"001"),
cts:not-query(cts:element-attribute-value-query(xs:QName("subject"),xs:QName("role"),"cross"))),0)
)
</code>
But it does not(returns an empty sequence). Please give me one that does.