xpath - Returning empty string when attribute does not match return text when attribute matches -
i need able keep track of in document particular value is. use xsl ecosystem i'm working in prevents that. i'm using java saxon-he 9.7.0-2 processor.
xml
<test> <value cat="fiction">at edge of orchard</value> <value cat="mythology">hero thousand faces</value> <value cat="fiction">spill simmer falter wither</value> </test>
xpath
for $a in /test return (if ($a/value[@cat="mythology"]) $a/value[@cat="mythology"] else "")
what see come is:
"" "hero thousand faces" ""
what i'm seeing is:
"hero thousand faces"
i think want iterate on every value
, check. below xpath should work you:
string-join((for $a in /test/value return (if ($a[@cat='mythology']) concat('"',$a,'"') else '""')),'
')
simplified:
string-join((for $a in /test/value return concat('"',($a[@cat='mythology'],'')[1], '"')) ,'
')
Comments
Post a Comment