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(_at_)onebox(_dot_)com - email
-----Original Message-----
From: Rudi Starcevic <tech(_at_)wildcash(_dot_)com>
Sent: Tue, 24 Jan 2006 21:53:29 +1000
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] 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>
--~------------------------------------------------------------------
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(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
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(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--