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

Re: Processing based on number - alternatives to recu

Subject: Re: Processing based on number - alternatives to recursion?
From: "Vyacheslav Sedov" <vyacheslav.sedov@xxxxxxxxx>
Date: Tue, 4 Mar 2008 19:14:04 +0300
Re:  Processing based on number - alternatives to  recu
xslt 2.0

<xsl:for-each select="1 to .">
...
</xsl:for-each>

On Tue, Mar 4, 2008 at 7:10 PM, Michael Ludwig <mlu@xxxxxxxxxxxxx> wrote:
> I have a numeric value in my XML and want to use it to control
>  some processing, say counting up until the number is reached, and
>  outputting a line in the process.
>
>  $ cat xtimes.xml
>  <Urmel>10</Urmel>
>
>  I use recursion and everything works fine. Is recursion the
>  preferred way to use a number to steer processing in XSL 1.0?
>
>  $ cat xtimes.xsl
>  <xsl:transform version="1.0"
>    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>    <xsl:output method="text"/>
>    <xsl:template match="Urmel"><!-- match element -->
>      <xsl:call-template name="rec">
>        <xsl:with-param name="iter" select="1"/>
>      </xsl:call-template>
>    </xsl:template>
>    <xsl:template name="rec"><!-- recursive template -->
>      <xsl:param name="iter"/>
>      <xsl:if test="not( $iter &gt; . )"><!-- Greater than me? -->
>        <xsl:value-of select="concat( $iter, '&#10;' )"/>
>        <xsl:call-template name="rec"><!-- Then recurse. -->
>          <xsl:with-param name="iter" select="$iter + 1"/>
>        </xsl:call-template>
>      </xsl:if>
>    </xsl:template>
>  </xsl:transform>
>
>  In order to use xsl:for-each, I'd have to dispose of something
>  generating a node-set based on my number, wouldn't I?
>
>  Is there anything like that in XSL 1.0 or 2.0?
>
>  Would that somehow be better?
>
>  Or is this misguided optimization thinking in thinking that lots of
>  template invocations are bad?
>
>  Michael

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.