[xquery-talk] XPath Expression help

Michael Kay mhk at mhk.me.uk
Wed Jul 19 22:59:08 PDT 2006


You may find people with more experience of the limitations of XPath 1.0
over on the xsl-list at www.mulberrytech.com.
 
The simplest solution that comes to mind is
 
dict/key[. != 'allowedkey1' and . != 'allowedkey2' and . != 'allowedkey3']
 
or if you prefer
 
dict/key[not(. = 'allowedkey1' or . = 'allowedkey2' ... etc)]
 
Michael Kay
http://www.saxonica.com/


  _____  

From: talk-bounces at xquery.com [mailto:talk-bounces at xquery.com] On Behalf Of
Todd Ditchendorf
Sent: 19 July 2006 20:09
To: talk at xquery.com
Subject: [xquery-talk] XPath Expression help


I realize this is an XQuery list, but I know that this list is particularly
good at constructing tricky XPath expressions, so I hope you don't mind.

I need some help constructing an XPath. I am currently restricted to XPath
1.0 syntax.

I have a document like this:

<dict>
<key>AllowedKey1</key>
<value/>
<key>AllowedKey2</key>
<value/>
<key>AllowedKey3</key>
<value/>
<key>UnrecognizedKey</key>
<value/>
</dict>



So I have fixed set of allowed <key> element string-values --
('AllowedKey1', 'AllowedKey2', 'AllowedKey3')

It is not required that all three be present. 0-unbounded allowed key values
may be present.

However, if there is a single key outside of that set, I would like to
detect it.

Can anyone create an XPath 1.0 expression that will return true if an
unrecognized key string-value is present?



Todd Ditchendorf
Software Engineer
itod at apple.com




-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://xquery.com/pipermail/talk/attachments/20060719/64c092a8/attachment.htm


More information about the talk mailing list