Wierdly some places {} are required and some places they are
not. Is there some kind of ruleset or guideline on that ??
Yes. It's called the language specification.
http://www.w3.org/TR/xslt#attribute-value-templates
Michael Kay
Here is the working XSL that should show anyone how to keep
pushing parameters as and when required in nested template
calls or apply templates
Abhishek Sanwal
HP - Houston Campus
abhishek(_dot_)sanwal(_at_)hp(_dot_)com
WORKING CODE:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template match="Matrix">
<xsl:param name="HeadAlign" select="'Right'"/>
<xsl:param name="DataAlign" select="'Right'"/>
<xsl:if test="contains(@HeadFlow,'H')">
<font class="debug">Horizontal</font>
<table border="0">
<xsl:apply-templates mode="H">
<xsl:with-param name="HeadAlign"
select="'Center'"/>
<xsl:with-param name="DataAlign"
select="'Center'"/>
</xsl:apply-templates>
</table>
</xsl:if>
<xsl:if test="contains(@HeadFlow,'V')">
<font class="debug">Vertical</font>
<table border="0">
<xsl:apply-templates mode="V">
<xsl:with-param name="HeadAlign"
select="'Left'"/>
<xsl:with-param name="DataAlign"
select="'Left'"/>
</xsl:apply-templates>
</table>
</xsl:if>
</xsl:template>
<xsl:template match="MatrixHeadArray" mode="H">
<xsl:param name="HeadAlign" select="'Right'"/>
<xsl:param name="DataAlign" select="'Right'"/>
<tr align="{$HeadAlign}">
<xsl:apply-templates mode="H">
<xsl:with-param name="HeadAlign" select="$HeadAlign"/>
<xsl:with-param name="DataAlign" select="$DataAlign"/>
</xsl:apply-templates>
</tr>
</xsl:template>
<xsl:template match="MatrixHeadCell" mode="H">
<xsl:param name="HeadAlign" select="'Right'"/>
<xsl:param name="DataAlign" select="'Right'"/>
<th align="{$HeadAlign}">
<xsl:apply-templates/>
</th>
</xsl:template>
<xsl:template match="MatrixDataArray" mode="H">
<xsl:param name="HeadAlign" select="'Right'"/>
<xsl:param name="DataAlign" select="'Right'"/>
<tr align="{$DataAlign}">
<xsl:apply-templates mode="H">
<xsl:with-param name="HeadAlign" select="$HeadAlign"/>
<xsl:with-param name="DataAlign" select="$DataAlign"/>
</xsl:apply-templates>
</tr>
</xsl:template>
<xsl:template match="MatrixDataCell" mode="H">
<xsl:param name="HeadAlign" select="'Right'"/>
<xsl:param name="DataAlign" select="'Right'"/>
<td align="{$DataAlign}">
<xsl:apply-templates/>
</td>
</xsl:template>
<xsl:template match="MatrixHeadArray" mode="V">
<xsl:param name="HeadAlign" select="'Right'"/>
<xsl:param name="DataAlign" select="'Right'"/>
<xsl:for-each select="MatrixHeadCell">
<tr>
<th align="{$HeadAlign}">
<xsl:apply-templates/>
</th>
<xsl:variable name="headloc">
<xsl:value-of select="@i"/>
</xsl:variable>
<xsl:for-each select="../../MatrixDataArray">
<td align="{$DataAlign}">
<xsl:apply-templates
select="MatrixDataCell[(_at_)i=$headloc]"/>
</td>
</xsl:for-each>
</tr>
</xsl:for-each>
</xsl:template>
<xsl:template match="MatrixDataCell" mode="V"/>
<xsl:param name="HeadAlign" select="'Right'"/>
<xsl:param name="DataAlign" select="'Right'"/>
</xsl:stylesheet>
-----Original Message-----
From: SANWAL, ABHISHEK (HP-Houston)
Sent: Wednesday, September 10, 2003 5:31 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] how to pass parameters down through nested
templates using xsl:apply templates in a nested fashion?
Wendell,
Just made the changes you suggested. But still have an issue.
Please correct the following if they are wrong.
To push the initial value of the parameter - (Okay or not)
<xsl:with-param name="HeadAlign" select="'Center'"/>
<xsl:with-param name="DataAlign" select="'Left'"/>
To obtain the parameter value in the called template (with default
values)
<xsl:param name="HeadAlign" select="'Right'"/>
Its just a literal string that I want to place in the <th>,
<td> or <tr> tags to set the text alignment of the cell. Like
this... (doesn't work) To push the value of the parameter
out. (Should I use XSL"value of and how would I actually
write it into the the following HTML tags ??
<tr align="$HeadAlign">
<th align="$HeadAlign">
<td align="$DataAlign">
Unfortunately it wont "spit" out those parameters into the
th, tr, td values. I have tried this with curly braces and
without and etc.
Of course I am getting nowhere with the trial and error.
Please let me know what would be the correct "syntax" for the
THREE XSL statements as mentioned above. (to make this possible :( ).
Thanks a lot.
Abhishek Sanwal
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list