Re: [xsl] Strange Sorting Problem

Subject: Re: [xsl] Strange Sorting Problem
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 3 Dec 2003 14:58:30 GMT
a refugee from xml-dev:-)

  will append the xml and xslt inline. sorry for the bucket load of code
  but thought it best! ;)

er well complete input and output is always good, but i think you could
easily have deleted 90% of the stylesheet for the purposes of
demonstrating the problem.

as explained on xml-dev

 <xsl:sort select='$sorted_field'

is a constant sort key so does not sort anything, you would want

 <xsl:sort select='*[name()=$sorted_field'

but.. you say

> but whilst the variable i am using to implement the sort is populated 

I'm not sure what you mean by populated, but it's out of scope, the
scope of a variable or parameter is the element containing the variable

In your case it is clearthat this template has no declaration for a
variable called sorted_field'
      <xsl:template name="workitem">
            <xsl:for-each select="descendant::*">

                  <xsl:sort select='$sorted_field'

You have

 <xsl:with-param name="sorted_field"

but you also need to declare the parameter of the template in the
template itself (unless it is a global param)

so  <xsl:template name="workitem">
     <xsl:param name="sorted_field"/>
            <xsl:for-each select="descendant::*">

I am not sure what you want to do here but you are selecting all the
descendent elements of workitem, but in your sample, all te hworkitem
elements had no descendent elements, they all just had a single text
node child containing a number, so you ares orting an empty list.

other unrelated things

  <img src='..\Images\asc.gif'>

is not a URI, URIs always use / not \

is not html (not that XSLT cares whether the html you generate is valid
or not)



This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:

 XSL-List info and archive:

Current Thread