Subject: [xsl] how to pass parameters down through nested templates using xsl:apply templates in a nested fashion? From: "SANWAL, ABHISHEK (HP-Houston)" <abhishek.sanwal@xxxxxx> Date: Wed, 10 Sep 2003 16:08:15 -0500 |
Peter Wendell + Other Experts Peter, I am using the MatrixXML(attached below) to Table Creation template you posted here to help me out. Other than that one below I am using a number of templates that call on others using <xsl:apply-templates select="abcd" mode = "xyz"> But now I need to add something to it. Parameter passing down the nested apply-templates to have a penetration of the "parameter" values as far as I choose using further <xsl:with-params... > and also be able to choose/between and modify values or send the original parameters the template was called with further down to the templates that would be called by the current template. An example of that is in the code below. Of course it does not work. At the first instance it sees this "<xsl:with-param name="HeadAlign" select="{$HeadAlign}"/>" It says "Invalid XPath Expression" While this works: <xsl:with-param name="HeadAlign" select="Left"/> Now I am curious if there is a way to pass that Incoming Parameter down to the next templates as my outgoing parameter? 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[@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.sanwal@xxxxxx XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] REtrieving attributes wit, Wendell Piez | Thread | RE: [xsl] how to pass parameters do, Michael Kay |
Re: [xsl] Excel Spreadsheet problem, David Mitchell | Date | RE: [xsl] few nodes are missing ??, Americo Albuquerque |
Month |