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
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
- XSLT Help and Discussion (7625)
-> + Use of before and after string (3) Sticky Topic
-> - How do I substitute element ty... (1)
-> + How does one add working days ... (4)
-> - Help, I have existing XLT and... (1)
-> + Need help on XSLT issue - (2)
-> + EDI to XML Conversion (7)
-> - XML To JSON Conversion using X... (1)
-> + Formatting Paragraphs to same ... (2)
-> - Grouping of records (1)
-> + Problems with xsd 1.1 (4)
-> + XML to HL7 mapping (3)
-> + XSLT 3 and Iterate (2)
-> + XSL-FO to PDF preview (3)
-> + java.lang.RuntimeException: Er... (2)
-> + Create Acroforms with Stylus X... (2)
-> + How to change XSLT parameter s... (3)
-> + how to change format of the da... (2)
-> + Search "Next 8 Results " doesn... (2)
-> - Support for Git (1)
-> + newbee (8)
-- [1-20] [21-40] [41-60] Next
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
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

   
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.