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

Re: Selecting case insensitively

Subject: Re: Selecting case insensitively
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Fri, 11 Aug 2000 20:47:09 +0100
xpath lowercase translate
Doug,

>I'm developing an XML glossary, and want to update the "select" attribute of
>the xsl:template based on what people type (a few characters) in a search
>text input field. Is there any way to select case-_in_sensitively? Do I need
>to write functions which create different mixed-case versions of what's
>typed, and then use these versions with "or" in the select predicate/filter?
>Or is there an easier way (I hope)?

I'm not exactly sure what you're doing: there's no 'select' attribute on
xsl:template, for example (you probably mean xsl:apply-templates?).

One good method for testing in a case-insensitive way is to translate both
the things you're testing into lowercase (or uppercase) and testing for
equality or whatever with the translated strings.

Define variables for uppercase and lowercase letters:

<xsl:variable name="lowercase" select="'abcdefghijklmnopqrstuvwxyz'" />
<xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />

Then use the translate() function to translate the two things you're
comparing into lowercase and compare them:

  translate($word1, $uppercase, $lowercase) =
  translate($word2, $uppercase, $lowercase)

You can put this test within a predicate in an XPath, of course.

I hope that approximates to what you were after,

Jeni

Dr Jeni Tennison
Epistemics Ltd * Strelley Hall * Nottingham * NG8 6PE
tel: 0115 906 1301 * fax: 0115 906 1304 * email: jeni.tennison@xxxxxxxxxxxxxxxx


 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.