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

RE: !!!counters in XSL!!!

Subject: RE: !!!counters in XSL!!!
From: "Ignacio J. Ortega" <nacho@xxxxxxxx>
Date: Thu, 5 Apr 2001 11:36:25 +0200
recursivity variable xsl
> can anyone please tell me whether you can have counters in 
> XSL? I mean I
> want to increment a variable each time I go into a certain 
> for-each loop.
> 

Hola a todos, Rosa:

Some time ago i've developed a way to do simple interations with no
recursivity, only valid for short numbers of iterations  useful for  i.e
months..

This can be easily modified to do a bunch of other things..

You can use a external generated document for big interations, but it's
not very performant, i think, 2 parses...

Perhaps somebody finds that useful..( at least it's usefull for me :)

My 0.02 ? ( nothing compared to the income i've got from the xsl-list :)

Saludos ,
Ignacio J. Ortega

PS.:( this adapted from my code, i've not tested it , sorry if it
contains any errors )

8<--------------------------------------------------------------------
<xsl:stylesheet version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:d="data"
>
<xsl:output method="text" indent="no" encoding="ISO-8859-1" />
  <!-- data for the transform -->
  <!-- adding d:item elemnts varies the counter -->
  <!-- you can use the index value for something -->
  <d:counter>
    <d:item>1</d:item>
    <d:item>2</d:item>
    <d:item>3</d:item>
    <d:item>4</d:item>
  </d:counter>
  <xsl:template match="/">
    <fourtimesoriginaltree>
    <xsl:variable name="backptr" select="."/>
    <xsl:for-each select="document('')//d:counter/d:item">
        <!--- Output some elements or do some iterative work -->
        <!-- use backptr for the original context tree       -->
        <!-- the example copies the source tree 4 times to the output
tree -->
        <originaltree copy="{.}">
            <xsl:copy-of select="$backptr"/>
        </originaltree>    
    </xsl:for-each>
    </fourtimesoriginaltree>
  </xsl:template>  
</xsl:stylesheet>
8<--------------------------------------------------------------------

 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.