[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Natural Sort
Try using a substring function to sort on the portion of the dn attribute that comes after "media" and before ".". <xsl:sort select="substring-after(substring-before(@dn,'.',").'media') " data-type="number"/> UNTESTED, -- Charles Knell cknell@xxxxxxxxxx - email -----Original Message----- From: Rudi Starcevic <tech@xxxxxxxxxxxx> Sent: Tue, 24 Jan 2006 21:53:29 +1000 To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Natural Sort Hi, I'm having trouble sorting my output. Using PHP as an example there is 'sort' and 'natural_sort' functions. This is my current output, I'm wanting the output to list from media1 not from media10. I've searched the archives but so far I've not found anything, mostly been searching under 'natural sort' so this could be a good one to add. Any advice much appreciated ... Sample Output: media10.mysite.com media11.mysite.com media12.mysite.com media13.mysite.com media14.mysite.com media15.mysite.com media1.mysite.com media2.mysite.com media3.mysite.com media4.mysite.com media5.mysite.com media6.mysite.com media7.mysite.com media8.mysite.com media9.mysite.com Sample XML: <servers> <server dn="media1.mysite.com" id="server392" os="FreeBSD 5.1"/> <server dn="media2.mysite.com" id="Server488" os="Fedora Core 1"/> ... <server dn="media10.mysite.com" id="Server433" os="Fedora Core 1"/> </servers> Sample XSL: <xsl:stylesheet version="1.0"> <xsl:template match="/"> <xsl:for-each select="/servers/server"> <xsl:sort select="@dn"/> <xsl:call-template name="list_servers"/> </xsl:for-each> <xsl:template name="list_servers"> <xsl:value-of select="@dn"/> </xsl:template> </xsl:template> </xsl:stylesheet>
|
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
|