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

Recursive Templates

Subject: Recursive Templates
From: Michael Stillwell <mjs@xxxxxxxxx>
Date: Mon, 2 Aug 1999 03:12:41 +1000 (EST)
recursive templates
I've just started using XSL and am wondering how to achieve the
transformation such as the following.  I want to transform

  <section>Introduction</section>
  
into (say)

  <caps><strong>Introduction</strong></caps>
  
My first attempt used templates like

  <xsl:template match="emph" name="emph">
  <strong>
  <xsl:apply-templates/>
  </strong>
  </xsl:template>

  <xsl:template match="section">
  <caps>
  <emph>
  <xsl:apply-templates/>
  </emph>
  </caps>
  </xsl:template>

Unfortunately, the <emph> ... </emph> tags produced but the "section"
template are not transformed into <strong> ... </strong> tags.  I
more or less understand why this is, but the best set of templates I
have found that do what I want are

  <xsl:template match="emph" name="emph">
  <strong>
  <xsl:copy-of select="$content"/>
  </strong>
  </xsl:template>

  <xsl:template match="section">
  <caps>
  <xsl:call-template name="emph">
    <xsl:with-param name="content">
      <xsl:apply-templates/>
    </xsl:with-param>
  </xsl:call-template>  
  </caps>
  </xsl:template>

I cannot help but think there is a better way.


Michael

-- 
:::: mjs@xxxxxxxxx ::::::::::::::::::::::::::::: http://beebo.org ::::
:::: mjs@xxxxxxxxx ::::::::::::::::::::::::::::: http://beebo.org ::::
:::: mjs@xxxxxxxxx ::::::::::::::::::::::::::::: http://beebo.org ::::


 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.