|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Using xsl:apply-templates with xsl: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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








