[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 <mail@xxxxxxxxxxxxxxxx>
Date: Tue, 15 Aug 2000 22:32:54 +0100
xsl uppercase
Michal,

>I tried to get "insensitively" unique records from a list and I failed,
what am
>I missing?

Within your template, the XPath you're using to figure out whether the
state is unique or not is:

  Test/location/state[not(translate(.,$lowercase,$uppercase)=
                          translate(following::state,$lowercase,$uppercase))]

In other words: find any states where there isn't a following state that
has the same content as this one (case insensitively).  For the last state
in your list, this will always be true: there are no states that follow
that one, so it's true that there are no states that have the same content
(case insensitive or not!).

As you're working through the list in document order, what you're probably
after is 'preceding' rather than 'following'.  Then, each state will appear
if no state with that name has already appeared.

  Test/location/state[not(translate(.,$lowercase,$uppercase)=
                          translate(preceding::state,$lowercase,$uppercase))]

The other alternative is to use keys to identify unique states.  Index each
of the states according to the key:

<xsl:key name="states" match="state"
         use="translate(., $lowercase, $uppercase)" />

And then retrieve only the unique ones using:

  Test/location/state[generate-id() =
         generate-id(key('states', translate(., $lowercase, $uppercase))[1])]

In other words, is the unique identifier for this state the same as unique
identifier for the first state retrieved using the key.  This will work
more efficiently if you have lots and lots of states in your document (and
if your XSLT processor supports keys).

I hope that this helps,

Jeni



Jeni Tennison
http://www.jenitennison.com/


 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.