Subject: Re: [xsl] sorting strings (not default sorting) with xslt From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Thu, 18 Mar 2010 13:27:58 +0100 |
I would like to sort following strings ['BSS84/A2', 'BSS84/DG', 'BSS84'],
default sorting results in:
BSS84/A2 -> BSS84/DG -> BSS84
But the customer wants them sorted like
BSS84 -> BSS84/A2 -> BSS84/DG
What's the easiest way to accomplish this?
Do I need to write a custom comparator function or can I use some <xsl:sort> shortcuts or is the only way to use collations?
t:\ftemp>type robby.xsl <?xml version="1.0" encoding="US-ASCII"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="/"> <xsl:for-each select="('BSS84/A2', 'BSS84/DG', 'BSS84')"> <xsl:sort/> <xsl:value-of select="."/> <xsl:text> </xsl:text> </xsl:for-each> </xsl:template>
t:\ftemp>xslt2 robby.xsl robby.xsl BSS84 BSS84/A2 BSS84/DG
-- XSLT/XQuery training: San Carlos, California 2010-04-26/30 Principles of XSLT for XQuery Writers: San Francisco,CA 2010-05-03 XSLT/XQuery training: Ottawa, Canada 2010-05-10/14 XSLT/XQuery/UBL/Code List training: Trondheim,Norway 2010-06-02/11 Vote for your XML training: http://www.CraneSoftwrights.com/s/i/ Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] sorting strings (not default , Robby Pelssers | Thread | [xsl] negative double, very small a, Wolfgang Laun |
RE: [xsl] exslt random:random-seque, Michael Kay | Date | Re: [xsl] exslt random:random-seque, Mike Odling-Smee |
Month |