Subject: Re: Selecting case insensitively From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> Date: Tue, 15 Aug 2000 22:32:54 +0100 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: Selecting case insensitively, Michal_Mart | Thread | Re: Selecting case insensitively, Michal_Mart |
dtd, xsl list | Date | RE: [ANN] Change Stylesheet Power T, Chris Bayes |
Month |