Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


[xsl] Nesting xsl:call-template

From: Winchel 'Todd' Vincent III <winchel@-------------->
To:
Date: 4/3/2007 3:46:00 PM
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 XMLSpy">XMLSpy 2007 set to use MSXML 4.0.  I tried using the XMLSpy">XMLSpy 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


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent