[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Sorting and position

Subject: Sorting and position
From: Patrick Cauldwell <Patc@xxxxxxxxxxxx>
Date: Wed, 10 Nov 1999 08:25:35 -0800
sorting by position
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.