[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Correctly sorting ID's

Subject: RE: Correctly sorting ID's
From: Américo Albuquerque <aalbuquerque@xxxxxxxxxxxxxxxx>
Date: Tue, 21 Jan 2003 15:44:47 -0000
hi cm09
Hi Niki.
You are sorting strings, not numbers, so you'll have to change a bit
your sorting criteria:
<xsl:sort select="substring(node()/@id,3)" data-type="number"/>

Hope this helps you.

-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Niki Dinsey
- CSW
Sent: terça-feira, 21 de Janeiro de 2003 15:24
To: xsl-list-digest@xxxxxxxxxxxxxxxxxxxxxx
Subject:  Correctly sorting ID's


Hi there list guru's, I have a question.

In a transform, is it possible to correctly sort these poorly formed
id's listed below

Currently my standard sort:

<xsl:apply-templates>
	<xsl:sort select="node()/@id"/>
</xsl:apply-templates>

Returns this:

<someNode id="CM09.1"/>
<someNode id="CM09.1.5"/>
<someNode id="CM09.10"/>
<someNode id="CM09.10.10.3"/>
<someNode id="CM09.10.15"/>
<someNode id="CM09.18.2"/>
<someNode id="CM09.2"/>
<someNode id="CM09.2.2"/>
<someNode id="CM09.22"/>
<someNode id="CM09.22.1"/>

it's the old classic... 1 then 10 before 2 etc.

I really need them sorted like the following:

<someNode id="CM09.1"/>
<someNode id="CM09.1.5"/>
<someNode id="CM09.2"/>
<someNode id="CM09.2.2"/>
<someNode id="CM09.10"/>
<someNode id="CM09.10.10.3"/>
<someNode id="CM09.10.15"/>
<someNode id="CM09.18.2"/>
<someNode id="CM09.22"/>
<someNode id="CM09.22.1"/>

I'm looking now to see if I can work this out and I was wondering if
anybody would be able to help me with the correct sort selection.

The only other issue to be aware of is that the dots can go on
indefinitely and I don't know until runtime the highest number of dot's
in the any one id will be.

If anybody could point me to a resource that deals with this I would be
most grateful.

Regards,

Niki Dinsey



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.