RE: [xsl] Adjusting sorted list

Subject: RE: [xsl] Adjusting sorted list
From: TSchutzerWeissmann@xxxxxxxxxxxxxxxx
Date: Thu, 16 May 2002 16:07:06 +0100
Hello Andrew,

How about this: 

<xsl:stylesheet version='1.0'

<xsl:key name='bs' match ='b' use='.'/>

	<xsl:template match='/'>
		<xsl:apply-templates select='*'/>

	<xsl:template match ="a">
		<xsl:variable name='uniques' select='b[count(. | key("bs",
.)[1]) = 1]'/>>
		<xsl:for-each select='b'>
			<xsl:sort select='.'/>
				<xsl:attribute name='rank'>
select='count($uniques[. &lt; current()]) + 1'/>


It's the only way I can think of doing it.

Tom Weissmann

-----Original Message-----
From: Andrew Timberlake [mailto:andrew.lists@xxxxxxxxx]
Sent: 16 May 2002 15:05
To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] Adjusting sorted list

I have the following XML:

I am trying to generate the following ouput:
    <b rank="1">1</b>
    <b rank="2">4</b>
    <b rank="2">4</b>
    <b rank="3">6</b>
    <b rank="3">6</b>
    <b rank="4">7</b>
    <b rank="5">8</b>
    <b rank="6">9</b>

Using xsl:for-each with a sort on b and then using position() I can get
a ranking from 1 to 8 but I have no idea how to achieve the above.

I have dug around in the archives for some ideas but to no avail.
I see that I can't use a variable and adjust it's value with each
iteration (as it's not actually iterating).
I have also looked into using a recursive named template but am not sure
how to achieve the above and sort the output???

Thanks in advance for any help.


 XSL-List info and archive:

 XSL-List info and archive:

Current Thread