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

Using xsl:apply-templates with xsl:with-param

Subject: Using xsl:apply-templates with xsl:with-param
From: "Ron Ten-Hove" <rtenhove@xxxxxxxxx>
Date: Mon, 15 May 2000 13:09:27 -0700
xsl apply templates with param
How is xsl:with-param supposed to work from within an xsl:apply-templates
element?  The recommendation doesn't seem to actually spell it out, other
that saying it is allowed.  Consider the following:

XSL STYLESHEET:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="1.0">
    <xsl:output indent="yes"/>

    <xsl:template match="/">
        <root>
            <xsl:apply-templates>
                <xsl:with-param name="param">List</xsl:with-param>
            </xsl:apply-templates>
        </root>
    </xsl:template>

    <xsl:template match="chapter">
      <xsl:param name="param">Unset</xsl:param>
      <chap>
        <xsl:attribute name="title"><xsl:value-of
select="@name"/></xsl:attribute>
        <xsl:attribute name="cat"><xsl:value-of
select="$param"/></xsl:attribute>
      </chap>
    </xsl:template>

    <xsl:template match="text()" />
</xsl:stylesheet>

XML SOURCE:
<?xml version="1.0"?>
<doc>
  <chapter name="The beginning">
    Alpha.
  </chapter>
</doc>

Both XT and SAXON give the same result:

<?xml version="1.0" encoding="utf-8" ?>
<root>
   <chap title="The beginning" cat="Unset"/
</root>

the "cat" attribute value is "Unset", rather than what I'd naively expect:
the
parameter value supplied by the apply-templates element.  How are parameters
supplied by xsl:apply-templates elements to be treated?

-Ron


 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.