[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message]

contains and tokenize

David Carlisle davidc at nag.co.uk
Mon Oct 23 17:10:29 PDT 2006


  contains and tokenize
you could use matches instead of contains and add  some word boundaries
to your regex. Schema/xpath regexp don't have built in word boundary
excpressions, but depending on your language rules something like

matches($text,concat('(^|[ ,\.;])',$keyword,($|[ ,\.;])'),'i')
for a case insensitive match against the keyword combined with either
the beginning or end of a string or a space , or ;.

If you want to use tokenize then you want = not contains, something like

upper-case($keyword) = tokenize(upper-case($text),'(\s|[\.,;])+'

which returns the sequence of words and then tests if any of them is
equal to the keyword. 

(There are some differences, a case insenitive match for example isn't
the same thing as upper casing and then comparing, see 
http://www.w3.org/TR/xpath-functions/#flags
)

David


Purchase Stylus Studio Online Today!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.