[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
RE: [xsl] Need help with special sorting
Subject: RE: [xsl] Need help with special sorting From: "Bert" <arm@xxxxxxxxx> Date: Tue, 29 Jun 2004 16:33:54 +0200 |
Hi Ken, Wow. Thanks a lot. Bert -----Original Message----- From: G. Ken Holman [mailto:gkholman@xxxxxxxxxxxxxxxxxxxx] Sent: zondag 27 juni 2004 21:07 To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: [xsl] Need help with special sorting At 2004-06-27 20:16 +0200, Bert wrote: >I need some help with 'special sorting'. >I have this xml-file (simplified). > ><alfabet> > <letter>a</letter> > <letter>b</letter> > <letter>c</letter> > <letter>d</letter> ></alfabet> > >The outcome after sorting should however be this: >a b d c > >The letter c has always to be the last item after sorting. >How can I achieve this? By translating the letters you have into the letter-order you want sorted for the purposes of calculating the collation string for each member of the sort. I hope the example below helps. ................ Ken T:\ftemp>type bert.xml <alfabet> <letter>a</letter> <letter>b</letter> <letter>c</letter> <letter>d</letter> </alfabet> T:\ftemp>type bert.xsl <?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE xsl:stylesheet [ <!ENTITY given 'abcdefghijklmnopqrstuvwxyz'> <!ENTITY needed 'abzcdefghijklmnopqrstuvwxy'> ]> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="text"/> <xsl:template match="/"> <xsl:for-each select="/*/letter"> <xsl:sort select="translate(.,'&given;','&needed;')"/> <xsl:value-of select="."/> <xsl:text> </xsl:text> </xsl:for-each> </xsl:template> </xsl:stylesheet> T:\ftemp>saxon bert.xml bert.xsl a b d c T:\ftemp> -- Public training 3 days XSLT & 2 days XSL-FO: Phoenix,AZ 2004-08-23 World-wide on-site corporate, govt. & user group XML/XSL training. G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) Male Breast Cancer Awareness http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal --+------------------------------------------------------------------ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/ or e-mail: <mailto:xsl-list-unsubscribe@xxxxxxxxxxxxxxxxxxxxxx> --+--
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Need help with special so, G. Ken Holman | Thread | RE: [xsl] Is this a Saxon 8.0 bug ?, David . Pawson |
Re: AW: [xsl] Processing an xml cat, Nicolas Mailhot | Date | How to supply a global parameter to, Colin Paul Adams |
Month |
Keywords