xsl-list
[Top] [All Lists]

RE: how to pass parameters down through nested templates using xsl:apply templates in a nested fashion?

2003-09-10 15:57:32
Now I am curious if there is a way to pass that Incoming 
Parameter down to the next templates as my outgoing parameter?

Of course. <xsl:with-param name="x" select="$x"/>

Michael Kay



If I can use a "local" variable to store the incoming 
parameter and then output it, then how can I do that? Please 
show me with a small code sample.

I appreciate all your help. If you do know a way or have any 
ideas or a web link for tutorial/discussion that will help me 
do so please let me know.

Thanks,

Abhishek

COMPLETE CODE ATTACHED BELOW:

<?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>

Abhishek Sanwal
HP - Houston Campus
abhishek(_dot_)sanwal(_at_)hp(_dot_)com



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



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