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

RFC: Recursive Template Improvements/Suggestions ??

Subject: RFC: Recursive Template Improvements/Suggestions ??
From: "Bovy, Stephen J" <STEPHEN.Bovy@xxxxxx>
Date: Thu, 2 Jun 2005 20:15:54 -0400
rfc template
Any suggestions for improvement would be greatly appreciated !!!

<script tag >

var btxt = "";                     // frame 3 table body text
function bt ( tg ) { btxt += tg; } // concatenate text function

// write table body frame 3
function body ( ) {
  bt('<html> ');

  ( ... )

  <  apply templates >

  ( ... )

   return btxt;
 } // end of table body frame 3

<end script tag>

<xsl:template match="/*/*/*" >
bt('<td align="center" nowrap="nowrap"> ');
<xsl:call-template name="repQuote">
  <xsl:with-param name="tbef" select="string('')"/>
  <xsl:with-param name="taft" select="."/>
  <xsl:with-param name="stop" select="0"/>
</xsl:call-template>
bt('</td> ');
</xsl:template>

Here is my XSL recursive template function:

<!-- recursive function to escape quote in -->
<!-- javaScript string literal assignment  -->
<xsl:template name="repQuote">
  <xsl:param name="tbef"/>
  <xsl:param name="taft"/>
  <xsl:param name="stop"/>
<xsl:choose>
<xsl:when test="$stop=0">
  <xsl:choose>
  <xsl:when test="contains($taft,'&quot;')">
    <xsl:variable name="xx">
      <xsl:value-of select="substring-before($taft,'&quot;')"/>
    </xsl:variable>
    <xsl:variable name="yy">
      <xsl:value-of select="substring-after($taft,'&quot;')"/>
    </xsl:variable>
    <xsl:variable name="zz">
      <xsl:value-of select="concat($xx,'\&quot;')"/>
    </xsl:variable>
    <xsl:call-template name="repQuote">
      <xsl:with-param name="tbef" select="concat($tbef,$zz)"/>
      <xsl:with-param name="taft" select="$yy"/>
      <xsl:with-param name="stop" select="0"/>
    </xsl:call-template>
  </xsl:when>
  <xsl:otherwise>
    <xsl:call-template name="repQuote">
      <xsl:with-param name="tbef" select="concat($tbef,$taft)"/>
       <xsl:with-param name="taft" select="string('')"/>
       <xsl:with-param name="stop" select="1"/>
     </xsl:call-template>
   </xsl:otherwise>
   </xsl:choose>
 </xsl:when>
 <xsl:otherwise>
   bt(&quot;<xsl:value-of select="$tbef"/>&quot;);
 </xsl:otherwise>
 </xsl:choose>
 </xsl:template>

Any suggestions for improvement would be greatly appreciated !!!

-----Original Message-----
From: JBryant@xxxxxxxxx [mailto:JBryant@xxxxxxxxx]
Sent: Thursday, June 02, 2005 2:43 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  Re: Recursive Template ??

If you dig around in the archives, you'll find oodles of them.

The general principle works like this:

<xsl:template name="someTemplate">
  <xsl:param name="someParam"/>
  <!-- do some processing -->
  <xsl:if test="not(someStopCondition)"
    <xsl:call-template name="someTemplate">
      <xsl:with-param name="someParam" select="someValue"/>
    </xsl:call-template>
  </xsl:if>
</xsl:template>

Endless variations exist, but they all come down to the following
proposition: recuse as many times as needed until some stop condition is
met.

HTH

Jay Bryant
Bryant Communication Services
(presently consulting at Synergistic Solution Technologies)





"Bovy, Stephen J" <STEPHEN.Bovy@xxxxxx>
06/02/2005 04:32 PM
Please respond to
xsl-list@xxxxxxxxxxxxxxxxxxxxxx


To
<xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
cc

Subject
Spam: Recursive Template ??






Is it possible to create a "recursive" template
that works in the same way as a recursive function call ???

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.