Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


xpath: predicate to choose only elements that match a one of a list of values

From: Phantom <phantom@-------.--->
To: 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.



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent