[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Generating serial no.s for XML tags

Subject: RE: Generating serial no.s for XML tags
From: Mukul <mukulw3@xxxxxxxxx>
Date: Mon, 28 Apr 2003 04:52:28 -0700 (PDT)
serial no
Thank you for reply. This is exactly I needed. Its
quite simple. Thanks Marcus for your reply also .. 

Regards,
Mukul

--- Jarno.Elovirta@xxxxxxxxx wrote:
> Hi,
> 
> > I want to write a XSLT which displays serial no.s
> as
> > the <tag> TAGs are found
> > 
> > I have written a XSL as below -
> > <?xml version="1.0" encoding="UTF-8"?>
> > <xsl:stylesheet version="1.0"
> > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
> > <xsl:template match="rootelem/tag">
> >      <xsl:value-of select="count(preceding::tag) +
> 1"
> > />
> >      
> >      <xsl:if test="total">
> >           <xsl:value-of
> select="count(preceding::tag)
> > + 1" />
> >      </xsl:if>
> > 
> > </xsl:template>
> > </xsl:stylesheet>
> > 
> > I want that when <total> tag comes , an extra
> serial
> > no. gets generated which is one more than the
> previous
> > one. After the serial no. of <total> tag is o/p,
> the
> > next serial no. resumes as 1 more than this.
> > 
> > The above stylesheet is generating output as
> 122345566
> > . I want the o/p to come as 123456789(this
> includes
> > serial no.s for <total> tag).
> 
> <xsl:template match="tag">
>   <xsl:variable name="x"
> select="count(preceding::tag) +
> count(preceding::tag[total]) + 1" />
>   <xsl:value-of select="$x"/>
>   <xsl:if test="total">
>     <xsl:value-of select="$x + 1" />
>   </xsl:if>
> </xsl:template>
> 
> But you might want to consider writing e.g. a
> recursive template to generate the serial number to
> eliminate the use of preceding axis.
> 
> Cheers,
> 
> Jarno - Assemblage 23: Document (Endanger Mix)
> 
>  XSL-List info and archive: 
> http://www.mulberrytech.com/xsl/xsl-list
> 


__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.