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)
-> + XSLT How to include the '<' sy... (2)
-> - HELP: Functional XSLT Implemen... (1)
-> - Cannot find a matching 1-argum... (1)
-> + XSLT a:? (2)
-> + Attribute Value Concatenation (2)
-> - Why is the WYSIWYG xslt editor... (1)
-> + WebService Call Error: Ref ele... (4)
-> + How to replace value of a fiel... (2)
-> + Schema Validation Problems (3)
-> + Reusing a prior valid value in... (5)
-> + Clutching at straws! (2)
-> - Adding a number to a for each ... (2)
-> ->Adding a number to a for ...
-> + Transform Name Value pairs int... (4)
-> + Transform the XML Scheme with ... (2)
-> + create XML drop down lists (2)
-> + error during stylesheet tutori... (3)
-> + Modify the value in a element ... (2)
-> + Call to extension function fai... (2)
-> + Convert XML Schema to XML - Mi... (2)
-> + How to calculate maximun RowCo... (3)
-- Previous [661-680] [681-700] [701-720] 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.