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

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

Suppose you have the following XML:

		<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">

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.



 XSL-List info and archive:

Current Thread