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: value of xsl:param in xsl:sort


I assume that your xsl:sort is a child of a xsl:for-each or an 
xsl:apply-templates, and that the xsl:param is a child of an xsl:template or 
the top level, and that the xsl:param and xsl:sort are not together like you 
pasted, or else your stylesheet shouldn't work at all.  If that's not the 
case, then look at that first.

The problem is that xsl:sort converts the result of its select attribute with 
the string() function and uses that as the sort key.  So what you have is 
string($sortByElement), which is the same for every element since the value 
of $sortByElement never changes.  Since all the sort keys are identical, the 
sort has no effect.

Specifying the path directly would have a different result for each element 
in the sorted list.

Unfortunately you can't use a param or variable like this, since its value 
never changes.  If you need to use a complete XPath expression dynamically, 
look for an "evaluate" extension function for your specific processor.  
Otherwise, you are stuck with matching the name of a single child element, as 
someone else posted, by doing *[name() = $sortByElement].

On Wednesday 13 February 2002 20:41, Kunal H. Parikh wrote:
> Hi !
>
> ========================
> <xsl:param name="sortByElement">AuthorList/Author/Name</xsl:param>
> <xsl:sort select="$sortByElement" order="ascending"></xsl:sort>
> ========================
>
> The above code does not seem to be replacing the $sortByElement for the
> parameter.
>
> But, if I replace "$sortByElement" with "AuthorList/Author/Name",
> everything works out just fine.
>
> Can someone please suggest what mistake I am making ?
>
>
>
> TIA,
>
> Kunal
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

-- 
Peter Davis
It is very difficult to prophesy, especially when it pertains to the future.

 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]