This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: variables in sort statements: (was Grouping and Sorting on value inside group)
- From: TSchutzerWeissmann at uk dot imshealth dot com
- To: xsl-list at lists dot mulberrytech dot com
- Date: Wed, 12 Jun 2002 17:41:32 +0100
- Subject: RE: [xsl] variables in sort statements: (was Grouping and Sorting on value inside group)
- Reply-to: xsl-list at lists dot mulberrytech dot com
I think there's something strange going on with variables in sort
statemenents. I'm trying a simple version of what Peter was doing in the
previous thread.
The source looks like this:
<a>
<b id='1'>b1</b>
<d id='2'>2</d>
<b id='3'>b3</b>
<c id='1'>c1</c>
<c id='2'>c2</c>
<c id='3'>c3</c>
<b id='2'>b2</b>
<d id='1'>3</d>
<d id='3'>1</d>
</a>
and I want to group by @id, and order the grouping by the value of a
specific child of a, either b,c or d.
This doesn't work:
<xsl:variable name='sortcol' select='"d"'/>
<xsl:for-each select='a/*[generate-id() =
generate-id(key("key",@id))]'>
<xsl:sort select='../*[local-name() = $sortcol][@id
= current()/@id]'/>
<x><xsl:value-of select="@id"/></x>
The @ids come out 1, 2, 3
This does work:
<xsl:variable name='sortcol' select='"d"'/>
<xsl:for-each select='a/*[generate-id() =
generate-id(key("key",@id))]'>
<xsl:sort select='../*[local-name() = "d"][@id =
current()/@id]'/>
<x><xsl:value-of select="@id"/></x>
The @ids come out 3, 2, 1, as desired.
Anyone able to help?
Thanks,
Tom
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list