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

Nesting xsl:call-template

Subject: Nesting xsl:call-template
From: Winchel 'Todd' Vincent III <winchel@xxxxxxxxxxxxxx>
Date: Tue, 3 Apr 2007 11:45:27 -0400 (GMT-04:00)
 Nesting xsl:call-template
Hello All:

I am nesting xsl:call-template nodes and am not getting the desired result.  I'm wondering whether I have made simple mistake or whether nesting of the xsl:call-template is not supported as I assume.

1. The following works as I expect it:

<tr>
<xsl:call-template name="TableCell">
	<xsl:with-param name="Value">This is some text.</xsl:if></xsl:with-param>
	<xsl:with-param name="Style">TableHeading</xsl:with-param>
	<xsl:with-param name="Colspan">2</xsl:with-param>
</xsl:call-template>
<tr>

<xsl:template name="TableCell">
	<xsl:param name="Value"/>
	<xsl:param name="Style"/>
	<xsl:param name="Type"/>
	<xsl:param name="Colspan"/>
	<xsl:element name="td">
		<xsl:if test="not($Style = '')">
			<xsl:attribute name="class"><xsl:value-of select="$Style"/></xsl:attribute>
		</xsl:if>
		<xsl:if test="not($Colspan = '')">
			<xsl:attribute name="colspan"><xsl:value-of select="$Colspan"/></xsl:attribute>
		</xsl:if>
		<xsl:value-of select="$Value"/>
	</xsl:element>
</xsl:template>

The resulting output is (which is what I want):

<tr>
   <td>This is some text.</td>
</tr>


2. This, however, does not work:


<xsl:template name="TableRow">
	<xsl:param name="ValueRow"/>
	<xsl:param name="StyleRow"/>
	<xsl:param name="TypeRow"/>
	<xsl:element name="tr">
		<xsl:if test="not($StyleRow = '')">
			<xsl:attribute name="class"><xsl:value-of select="$StyleRow"/></xsl:attribute>
		</xsl:if>
		<xsl:value-of select="$ValueRow"/>
	</xsl:element>
</xsl:template>

<xsl:template name="TableCell">
	<xsl:param name="Value"/>
	<xsl:param name="Style"/>
	<xsl:param name="Type"/>
	<xsl:param name="Colspan"/>
	<xsl:element name="td">
		<xsl:if test="not($Style = '')">
			<xsl:attribute name="class"><xsl:value-of select="$Style"/></xsl:attribute>
		</xsl:if>
		<xsl:if test="not($Colspan = '')">
			<xsl:attribute name="colspan"><xsl:value-of select="$Colspan"/></xsl:attribute>
		</xsl:if>
		<xsl:value-of select="$Value"/>
	</xsl:element>
</xsl:template>

<xsl:call-template name="TableRow">
	<xsl:with-param name="ValueRow">
		<xsl:call-template name="TableCell">
			<xsl:with-param name="Value">This is some text.</xsl:with-param>
			<xsl:with-param name="Style">TableHeading</xsl:with-param>
			<xsl:with-param name="Colspan">2</xsl:with-param>
		</xsl:call-template>
	</xsl:with-param>
</xsl:call-template>

The resulting output (which is not want I want or expect) is this:

<tr> This is some text. </tr>

This is XSLT 1.0.  I am using XML Spy 2007 set to use MSXML 4.0.  I tried using the XML Spy XSLT engine with the same results.  I looked in Michael Kay's XSLT 2nd Edition, but did not see any similar examples or tips.  I thought that I had created XSLT in the past that did this, but perhaps I'm mistaken.

Any advice would be greatly appreciated.

Thanks,

Todd

===========================
Winchel "Todd" Vincent III
<xmlLegal> http://www.xmllegal.org/ 
Phone : 404.822.4668
Fax     : 770.216.1633
Email : Todd.Vincent@xxxxxxxxxxxx

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-2007 All Rights Reserved.