xsl-list
[Top] [All Lists]

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

2008-12-11 11:17:08
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[(_at_)defid=3183315]//*[(_at_)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/

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>