[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Selecting case insensitively
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|