[xsl] Fwd: Re: unable to dynamically set sort order

Subject: [xsl] Fwd: Re: unable to dynamically set sort order
From: "bharat chintapally" <hydbad@xxxxxxxxxxx>
Date: Tue, 22 May 2001 09:28:44 -0400
Hi Dimitre:
Thanks for your reply, when I read about the xsl:sort, it seems to me that for the select attribute we can specify an expression (this can be any xpath expression ?). Well if I tried that (I specifed the XPath expression as "/xx/yy/zz/sortColumn", it doesn't seem to be working.. And for the order attribute, I can only use the string "ascending | descending". I can't even use a variable.. This seems to be weird restriction. Why can't this values be evaluated when a template is applied. BTW what is an AVT-s are you talking abour data stru. AVT.


Thanks
--bharat


From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
To: hydbad@xxxxxxxxxxx
CC: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: unable to dynamically set sort order
Date: Mon, 21 May 2001 21:37:28 -0700 (PDT)

This must be a FAQ!:

All attributes of xsl:sort with the exception of "select" can be specified as AVT-s.

The "select" attribute can be any XPath expression. Certainly, an attempt to put an
XPath expression in a variable and pass this variable as the (complete) value of the
"select: attribute -- this will fail for xsl: sort as in any such attempt in XSLT,
because XPath expressions are not evaluated dynamically.


However, if you need to specify the name of a child element, then you can use an
expression like this:


*[name()=$sortColumn]

Therefore, one possible way to achieve your wanted results is:

<xsl:sort order="{$order}" select="*[name()=$sortColumn]"/>

Cheers,
Dimitre Novatchev.

bharat chintapally wrote:

Hello All:
          I am trying to dynamically set sort order and sort column in my
XSLT. It seems that I can not use an expression for "order".

<xsl:apply-templates select="Uow">
   <xsl:sort select="$sortColumn" order="$sortOrder"/>
   <xsl:with-param name="from" select="$startRow"/>
   <xsl:with-param name="to" select="$endRow"/>
</xsl:apply-templates>

** $sortColumn and $sortOrder are variables here

Is there any other way I can solve this issue? The reason I need to do this
is to keep track of users preference between requests when they are
sorting..

Any ideas or help is really appreciated..

Thanks



__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/

_________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread