RE: [xsl] How to put sorted nodes into a variable? (to xsl:number a sorted node-set)

Subject: RE: [xsl] How to put sorted nodes into a variable? (to xsl:number a sorted node-set)
From: "Andrew Welch" <AWelch@xxxxxxxxxxxxxxx>
Date: Mon, 5 Jan 2004 13:16:04 -0000
Are you sure about your intended output here?  It seems that you want to
maintain the structure of your xml (and number it according to that) but
you want to sort the elements into that structure based on
@sequenceIndex...

For that to happen you will need to number the <thing> elements based on
xml structure, and then swap around the @key values based on
@sequenceIndex, but I still don't think that is what you are after.

cheers
andrew

> hello all,
> 
> I'm trying to 'xsl:number' some sorted multileveled nodes.
> 
> According to some messages I found in the archive of this 
> mailing list, I 
> should
> first put my sorted node-set into a xsl:variable. (Otherwise 
> numbering will 
> take place according
> to the order of nodes in the xml document!).
> 
> To reproduce my struggle:
> 
> a)  xml input:
> 
> <thing sequenceIndex="30" key="hardware">
> 	<thing sequenceIndex="20" key="computerB">
> 	</thing>
> 	<thing sequenceIndex="5" key="computerA">
> 		<thing sequenceIndex="5" key="diskOne">
> 		</thing>
> 		<thing sequenceIndex="10" key="diskTwo">
> 		</thing>
> 	</thing>
> <thing
> <thing sequenceIndex="10" key="software">
> </thing>
> 
> b) wished output: (sorted on attribute 'sequenceIndex')
> 
> 1 software
> 2 hardware
> 2.1 computerA
> 2.1.1 diskOne
> 2.1.2 diskTwo
> 2.2 computerB
> 
> c) xsl
> 
> <xsl:variable name="sorted-things" select="//Thing">
> 	<!-- see question 1 below -->
> </xsl:variable>
> 
> <xsl:for-each select="$sorted-things">
> 	<fo:block>
> 		<xsl:number level="multiple" grouping-size="1" 
> grouping-separator="."/>
> 		<xsl:text> </xsl:text>
> 		<xsl:value-of select="@key"/>
> 	</fo:block>
> </xsl:for-each>
> 
> 
> Question 1: how to put sorted nodes into the variable 
> ($sorted-things)? 
> Sortation according to <xsl:sort select="@sequenceIndex" 
> data-type="number" 
> order="ascending"/>.
> 
> Question 2: is this "use a variable"-strategy correct to 
> xsl:number a set of 
> nodes according to their sortation (and not their xml document order)?
> 
> any help appreciated,
> 
> Mathieu van Echtelt
> Groningen
> the Netherlands
> 
> _________________________________________________________________
> MSN Zoeken helpt je om de gekste dingen te vinden! 
http://search.msn.nl


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





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


Current Thread