Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries [Thread Prev] >Thread Next - Re: xpath: predicate to choose only elements that match a one of a list of values xpath: predicate to choose only elements that match a one of a list of valuesTo: NULL Date: 7/2/2008 11:59:00 PM
I totally need the help of the XML experts up here, I can't figure this
one out, I've been working on it for hours today, googling my brains
out.
I need to write an xpath query string that returns one or more specific
elements on the fly, in this example, apple and/or orange. *this* works
for JUST apple:
select xpath_eval('//apple',
xtree_doc('<fruit><apple>7</apple><orange>11</orange><banana
/></fruit>'))
BUT, how do I match on not just //apple but also //orange ?? (I have to
accomplish this with an XPATH, not a complex XQUERY 'when' clause
unfortunately.)
I even had it convoluted to this working version:
select xpath_eval('//*[local-name()=("apple")]',
xtree_doc('<fruit><apple>7</apple><orange>7</orange><banana
/></fruit>'))
... hoping I could then try to add orange with a pipe (|) operator:
local-name()=("apple"|"orange") ... no dice.
Both the source and the match value are coming in at run time, so a
series of OR clauses in the predicate won't work:
noGoExample: [local-name()="apple" or [local-name()="orange"]
I KNOW there's a simple representation for this, but just try looking
for it online when you don't know what you're looking for. like looking
for a word in the dictionary you don't know how to spell.
I thought of using an XML set, something like this:
[local-name() in {"apple|orange"}]
... but none of the dozen combinations of syntax and quoted variations worked.
I AM LOSING MY MIND!
any help folks? save my mind, thanks!
p.
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
