Sorting and position

Subject: Sorting and position
From: Patrick Cauldwell <Patc@xxxxxxxxxxxx>
Date: Wed, 10 Nov 1999 08:25:35 -0800
The question I have is how to I sort a node-list, then take only part of it.
Say for example I have:

<Products>
	<Product>
		<Name>B</Name>
	</Product>
	<Product>
		<Name>C</Name>
	</Product>
	<Product>
		<Name>A</Name>
	</Product>
	<Product>
		<Name>F</Name>
	</Product>
</Products>

and what I want to do is do something with the first two <Product> elements,
but I need to sort them by name first.

If I do this:

<xsl:template match="Products[position() >= 0 and position <= 1]">
	<xsl:for-each select="Product">
		<xsl:sort select="Name"/>
		<xsl:value-of select="Name"/>
	</xsl:for-each>
</xsl:template>

I end up with the first two in document order, then sorted.  How can I come
out with the first two in alpha order by Name?

Thanks,

Patrick

Patrick Cauldwell patc@xxxxxxxxxxxx (503) 892-4738 
STEP Technology, Inc. 6915 SW Macadam Suite 200, Portland, OR 97219 



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


Current Thread