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

Re: forth and back

Subject: Re: forth and back
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Sat, 21 Apr 2001 22:05:48 +0100
forth and back
Hi Tobi,

> I tried to write two recursing templates: the first is called
> "forth"; red and blue are icremented, and green is decremented. The
> second one works the otherway round. One should start the other as
> soon as one of the values reached the limlit of either 0 or 255.
> Both should stop as soon as the set level of depth is reached.

The important thing is that last one.  "Both should stop as soon as
the set level of depth is reached."  Looking at the templates, you
test $depth in both, but in both it's in an xsl:when and there's an
xsl:otherwise which catches the other option.  So for example:

<xsl:template name="back">
   ...
   <xsl:choose>
      <xsl:when test="$current &lt; $depth and ($red &gt; 0)
                      and ($green &lt; 255) and ($blue &gt; 0)">
         <xsl:call-template name="back">
            ...
         </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
         <xsl:call-template name="forth">
            ...
         </xsl:call-template>
      </xsl:otherwise>
   </xsl:choose>
</xsl:template>

You need to *not do anything* when $current &gt;= $depth, rather than
just going into xsl:otherwise.  So something like:

<xsl:template name="back">
   ...
   <xsl:choose>
      <xsl:when test="$current &gt;= $depth" />
      <xsl:when test="($red &gt; 0) and ($green &lt; 255)
                      and ($blue &gt; 0)">
         <xsl:call-template name="back">
            ...
         </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
         <xsl:call-template name="forth">
            ...
         </xsl:call-template>
      </xsl:otherwise>
   </xsl:choose>
</xsl:template>

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



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


Current Thread
  • forth and back
    • Tobias Reif - Sat, 21 Apr 2001 15:37:47 -0400 (EDT)
      • Jeni Tennison - Sat, 21 Apr 2001 17:06:02 -0400 (EDT) <=
      • <Possible follow-ups>
      • Tobias Reif - Sat, 21 Apr 2001 18:14:21 -0400 (EDT)

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.