[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] How to Reorder Items & Number Them Sequentially?
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|