[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

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


Subject: [xsl] How to put sorted nodes into a variable? (to xsl:number a sorted node-set)
From: "ongeaddresseerd ongeaddresseerd" <ongeadresseerd@xxxxxxxxxxx>
Date: Mon, 05 Jan 2004 11:50:24 +0000

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




Current Thread
Keywords
xml