XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Mark BerrySubject: Adding a number to a for each loop
Author: Mark Berry
Date: 24 Feb 2008 05:45 PM
Hi this is my first post to the forum. I guess I am asking a question that has been asked many times before. However, I am new to xsl and programming so I am looking for a nice simple answer that I can implement in my code.

In my code I have a for-each loop that extracts information for posting onto an electronic map. Each item posted to the map needs a unique identifier and this is not available in the xml that is being transformed. Therefore I need something that counts each time I execute the for-each loop so I can use it as an identifier for the item.
The loop contains 2 different types of item so I cannot use the node number as the unique identifier. For example I have a total of 6 items of 2 different types mixed up so I want A1, A2, A3, B1, B2, B3 if I use the node number I end up with A1,A2,B3,B4,A5,B6.
That may be too much detail but all I really need is some code that numbers the for-each loop each time it is executed.

Any help great fully accepted (this has been driving me nuts!)

Regards

Mark

Posttop
James DurningSubject: Adding a number to a for each loop
Author: James Durning
Date: 25 Feb 2008 11:10 AM
Could you show your xml?

It's probably possible to do it with xsl:number using the right count clause.
http://www.w3schools.com/xsl/el_number.asp

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.