Click to See Complete Forum and Search --> : dynamically sorting xml


xmlnewb007
05-06-2009, 06:16 AM
Hi,

I am hoping to find an answer in this forum as I have been searching the web with not much luck.
Essentially what I need is to allow the user to sort the xml by clicking on the header.
I am using xsl to display the content to the user.

I know that I will need to use javascript onclick function but I do not how to get it to pass the sort variable into the xsl:sort element.

any help would be great.

many thanks

jkmyoung
05-06-2009, 03:02 PM
Add a parameter into your xsl:
<xsl:param name="sortElement"/>

Set the parameter in the javascript:
(dependant on what transformation methods you're using. )

Assuming the node you're sorting by is a child of your row node, it'd be something like:
<xsl:sort select="*[local-name() = $sortElement]"/>
Or if a deeper child,
<xsl:sort select=".//*[local-name() = $sortElement]"/>