This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: variables in sort statements: (was Grouping and Sorting on value inside group)


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]