This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
passing parameters from one template to the other
- From: Ralph Holz <Ralph dot Holz at unique dot com>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Thu, 04 Apr 2002 21:59:10 +0100
- Subject: [xsl] passing parameters from one template to the other
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi,
I try to pass a parameter from one template to the other, like this:
<xsl:template match="itn">
<xsl:param name="title" />
<!-- transform all files that are linked via the @id attribute to
XHTML -->
<xsl:for-each select="menu/category">
<xsl:for-each select="item">
<xsl:variable name="name"><xsl:value-of
select="@id" /></xsl:variable>
<!-- <redirect:write file="C:\ralph\xml
schemas\itn\test.html">
<xsl:value-of select="text" />
</redirect:write> -->
<xsl:apply-templates
select="document(concat('C:\ralph\xml schemas\itn\', $name, '.xml'))">
<xsl:with-param name="title"><xsl:value-of
select="text" /></xsl:with-param>
</xsl:apply-templates>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
Where
<item><text>string</text></item>
And the template that is called is
<xsl:template match="newsdoc">
<xsl:param name="title" />
<xsl:variable name="name"><xsl:value-of select="@id" /></xsl:variable>
<redirect:write select="concat('C:\ralph\xml schemas\itn\', $name,
'.html')">
<html>
<head>
<title>ITN News Service</title>
</head>
<body>
<!-- <p>The value is: <xsl:value-of
select="$title" /></p> -->
<!-- <h1><xsl:value-of select="$title"
/></h1> -->
<xsl:for-each select="newschunk">
<p><xsl:value-of select="text" /></p>
</xsl:for-each>
</body>
</html>
</redirect:write>
</xsl:template>
Is that the correct way to accept the parameter in the second template?
Xalan produces an empty <h1> element when I try it. For testing purposes, I
evaluated the comment in the first template (redirect). The text element
showed to be non-empty, so there should be no error in the first template.
Thanks,
Ralph
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list