Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 13th, 2004, 12:17 AM
Registered User
 
Join Date: Jan 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Sequence of For-each elements?

Hi all,

can you help with this?
I need to dynamically name input fields based on the sequence of the node in the for-each result set, so I can reference and access the fields individually. Is there a way to do this?

i.e. need to replace X below with the sequence of each node returned:

<xsl:for-each select="Group/xml/rs:data/z:row[@SettingType != 'CB']">
  <tr>
  <td>Item X:</td>
  <td><input type="text" name="listitemX" size="30" value="{@SettingName}" /></td>
  <td>remove</td>
  </tr>
</xsl:for-each>

Cheers,
Brendon.

 
Old January 13th, 2004, 05:36 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Use position function, for a more advanced and customisable way look at the xsl:number element:
Code:
<xsl:for-each select="Group/xml/rs:data/z:row[@SettingType != 'CB']">
  <tr>
  <td>Item X:</td>
  <td><input type="text" name="listitem{position()}" size="30"   value="{@SettingName}" /></td>
  <td>remove</td>
  </tr>            
</xsl:for-each>
Joe (MVP - xml)
 
Old January 14th, 2004, 05:17 PM
Registered User
 
Join Date: Jan 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks - position() does just what I needed.






Similar Threads
Thread Thread Starter Forum Replies Last Post
how to create sequence no in c# bettiahamit .NET Framework 3.5 1 November 6th, 2008 06:25 AM
comparison using a sequence pcase XSLT 1 December 3rd, 2007 07:33 PM
Need to change Collation sequence kscase SQL Server 2005 2 April 9th, 2007 10:20 AM
Processing first node in a sequence djmarquette XSLT 3 November 15th, 2005 01:05 PM
value from a sequence suhabassam JSP Basics 0 September 27th, 2005 01:33 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.