This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

passing parameters from one template to the other


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]