Re: [xsl] How to sort a $variable and store that into another $variable ?

Subject: Re: [xsl] How to sort a $variable and store that into another $variable ?
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Thu, 11 Dec 2008 17:16:37 +0100
Jean-Philippe Martin wrote:

My need is :
- extract a list of values
- make it unique
- make it sorted
- put it on many columns in a html table

My XML document is big. I create an unordered list of unique values
with this call  (the first // is important since the info can be
anywhere in the xml tree) :

<xsl:variable name="unsortedList"
select="//category[@defid=3183315]//*[@attid=49]/node()[not(.=following::*)]"
/>

Your first post said you had troubles to sort nodes into a variable, the problem being "I get is a single node containing all the values sorted
concatenated in a single string". Can you show us the code that causes that problem?
What you did show in your second post did not even attempt to sort into a variable and output that sorted variable.


The only problem I see above is that the variable unsortedList could contain all kind of nodes (e.g. element nodes, text nodes, comment nodes) and I am not sure sorting such an incoherent node-set makes much sense.

And as I pointed out in my initial post, if you sort a node-set into a variable in XSLT 1.0 then you have a result tree fragment. If you want to apply XPath on a result tree fragment then you first need to apply an extension function like exsl:node-set to convert the result tree fragment into a node-set. So that could also be a problem, but you have not shown us your attempt to sort into a variable and to use that variable later so I am just guessing.

--

	Martin Honnen
	http://JavaScript.FAQTs.com/

Current Thread