[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: XPath Assistance

Subject: RE: XPath Assistance
From: "Passin, Tom" <tpassin@xxxxxxxxxxxx>
Date: Fri, 28 Mar 2003 17:20:53 -0500
xpath case insensitive compare
[ Scott Purcell]

> Also, in the above example: child::first='John'
> How could I find John if the name was lower case john?
> Eg: I would like to find John or john or JOHN or JOhn.
> 

Names in XML, as you probably know, are case-sensitive, and xslt does
not have a case-insensitive compare.  The usual way to do a
case-insensitive compare is to use the the translate() function.  Here
as an example, where I create separate variables.  You do not have to do
this but it is more readable, and easier if you will be doing several
such compares.

<xsl:variable name='uppers'
   select='"ABCDEFGHIJKLMNOPQRSTUVWXYZ"'/>
<xsl:variable name='lowers'
   select='"abcdefghijklmnopqrstuvwxyz"'/>

The test in your predicate could be something like this ("first" is the
shorthand syntax for "child::first") -

translate(first, $uppers, $lowers) = "john"

Notice that you need quotes around the two translation strings,
otherwise they would be understood as element names rather than as
strings.

Cheers,

Tom P

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

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-2013 All Rights Reserved.