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

How to Reorder Items & Number Them Sequentially?

Subject: How to Reorder Items & Number Them Sequentially?
From: Bill Entwistle <ent@xxxxxxxxx>
Date: Mon, 22 May 2000 00:08:37 -0500
reorder items
Greetings,

I would appreciate any suggestions that you can give on how to
accomplish the following simple task.

Suppose you have the following XML:

	<animals>
		<animal type="dog" name="Fido">
		<animal type="cat" name="Kitty">
		<animal type="bird" name="Tweety">
		<animal type="horse" name="Trigger">
		<animal type="cat" name="Tom">
		<animal type="pig" name="Porky">
		<animal type="fish" name="Charlie">
		<animal type="pig" name="Babe">
		<animal type="cow" name="Elsie">
		<animal type="cat" name="Puss">
	<animals>

and you want to transform this into the following output:

	Here are my pets:
	1.  dog (Fido)
	2.  cat (Kitty)
	3.  cat (Tom)
	4.  cat (Puss)
	5.  bird (Tweety)
	6.  horse (Trigger)
	7.  pig (Porky)
	8.  pig (Babe)
	9.  fish (Charlie)
	10.  cow (Elsie)

Notice that the elements are output in physical order, except when
there is more than one of the same type, in which case the duplicates
are grouped together with the first occurrence.

What I'd like to know is:  how I can create this ordering of the
output and retain the ability to number the items sequentially using
XSLT?  I have figured out a way to reorder the elements by using
nested for-each loops, but there appears to be no way to get
sequential numbering when I do it that way.  I'm sure there must be
a functional approach that makes this easy.

Thanks,

Bill


 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.