I need to be able to keep track of where in the document any particular value is. I would use XSL but the ecosystem I'm working in prevents that. I'm using the Java Saxon-HE 9.7.0-2 processor.
XML
<test>
<value cat="fiction">At the edge of the orchard</value>
<value cat="mythology">Hero with a thousand faces</value>
<value cat="fiction">Spill simmer falter wither</value>
</test>
XPath
for $a in /test
return
(if ($a/value[@cat="mythology"]) then
$a/value[@cat="mythology"] else
"")
What I would like to see come back is:
""
"Hero with a thousand faces"
""
What I'm currently seeing is:
"Hero with a thousand faces"