RE: [xsl] sort problem

Subject: RE: [xsl] sort problem
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Fri, 21 Mar 2003 22:54:43 -0000
	
	<xsl:variable name="poles" select="$prods/@pole" />
	<xsl:for-each select="$poles">
		<xsl:sort select="@pole" />
		<xsl:sort select="@time" data-type="number" />

The variable $poles holds a set of @pole attribute nodes. Your first
sort key is looking for the @pole attribute of one of these nodes: but
attributes do not have attributes.

      <xsl:variable name="times" select="$prods[@pole=current()]/@time"
/>
	<xsl:for-each select="$times">
		<!-- why isn't this sort working!! -->
		<xsl:sort select="$times" data-type="number"
order="ascending" />

The variable $times holds a set of @time attribute nodes. This time you
are calculating the sort key for each of these attributes as the value
of $times itself. The value of $times is the same for every node in
$times, so this sort is not going to be very effective.

You have obviously misunderstood the way xsl:sort works. You need to
specify a select expression that computes a sort key for a particular
node in the set being sorted. This expression is evaluated with that
node as the context node.

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx 

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Craig Kattner
> Sent: 21 March 2003 21:42
> To: XSL List (E-mail)
> Subject: [xsl] sort problem
> 
> 
> Sorry for not including samples, but the code is a bit more 
> than I like posting.
> 
> http://www.intermatic.com/temp/96-1.xml Source document 
http://www.intermatic.com/temp/96-2.xsl Stylesheet
http://www.intermatic.com/temp/96-2.html Output document (actual)
http://www.intermatic.com/temp/96-2-expected.html Output document
(expected)

If you look at the bottom of the output you can see the column on the
left is ordered 5, 15, 30, 60, 360, 720, 120, 240. It should be in
ascending order though. Why doesn't line 51 in the stylesheet sort them
in the expected order?

Secondly, I need to set the colspan property on the switch types (line
24) and finish types (line 28). But I don't see how I can count the
children using the grouping method I'm using here. Any pointers would be
appreciated.

Craig


 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