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 November 3rd, 2005, 12:35 PM
Authorized User
 
Join Date: Oct 2005
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default Occurance Index

Hi
   My XML file looks like

   <Country>
      <County>County1</County>
      <County>County2</County>
      <County>County3</County>
   </Country>

I want the output to be

1 County1
2 County2
3 County3

Can you plz help.
 
Old November 3rd, 2005, 02:36 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

<xsl:template match="County">
 <xsl:value-of select="position()"/>
 <xsl:text> </xsl:text>
 <xsl:value-of select="."/>
</xsl:template>

For more complex numbering you can use xsl:number.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old November 4th, 2005, 04:45 AM
Authorized User
 
Join Date: Oct 2005
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks a lot...






Similar Threads
Thread Thread Starter Forum Replies Last Post
Index carumuga SQL Server 2000 1 December 31st, 2007 12:42 PM
last occurance omitted - LOOP error? crmpicco Excel VBA 3 May 5th, 2005 01:45 PM
11th occurance ONLY crmpicco Classic ASP Basics 1 February 11th, 2005 04:01 AM
pick out the 11th occurance crmpicco Classic ASP Basics 4 February 11th, 2005 04:00 AM
xslt distinct and countnumber of occurance imran_py XSLT 1 May 5th, 2004 02:50 PM





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