xsl-list
[Top] [All Lists]

[xsl] Nesting xsl:call-template

2007-04-03 08:45:49
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(_dot_)Vincent(_at_)xmllegal(_dot_)org







--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>