In XSLT is it possible to use the value of an xpath expression in a call to a template using an par
- by Cell
I am performing an xsl transform and in it I call a template with a param using the following code
<xsl:call-template name="GenerateColumns">
<xsl:with-param name="curRow" select="$curRow"/>
<xsl:with-param name="curCol" select="$curCol + 1"/>
</xsl:call-template>
This calls a template function which outputs part of a table element in HTML. The curRow and curCol are used to determine which row and column we are in the table. gbl_maxCols is set to the number of columns in an html table
<xsl:template name="GenerateColumns">
<xsl:when test="$curCol <= $gbl_maxCols">
<td>
<xsl:attribute="colspan">
<xsl:value-of select="/page/column/@skipColumns"/>
</xsl:attribute>
</xsl:when>
</xsl:template>
The result of this function is a set of td elements, however some of these elements (those with a skipColumn attribute greater than 1 span more than 1 column, I need to skip this many columns with the next call to generateColumns.
this works just like I would expect in the case where I simply increment the curCol param but I have a case where I need to use the value from the xml attribute skipColumns in the math to calculate the value for curCol. In the above case I iterate through all the columns and this works for the majority of my use cases. However in same cases I need to skip over some of the columns and need to pass in that value from the xml attribute to calculate how many columns I need to skip.
My naive first attempt was something like this
<xsl:call-template name="GenerateColumns">
<xsl:with-param name="curRow" select="$curRow"/>
<xsl:with-param name="curCol" select="$curCol + /page/column/@skipColumns"/>
</xsl:call-template>
But unforutnately this does not seem to work. Is there any way to use an attribute from an xml page in the calculation for the value of a param in xsl.
My xml page is something like this (edited heavily since the xml file is rather large)
<page>
<column name="blank" skipColumns="1"/>
<column name="blank" skipColumns="1"/>
<column name="test" skipColumns="3"/>
<column name="blank" skipColumns="1"/>
<column name="test2" skipColumns="6"/>
</page>
after all of this I would like to have a set of td elements like the following
<td></td><td></td><td colSpan="3"></td><td></td><td colSpan="6"></td>
if I just iterate through the columns I instead end up with something like this which gives me more td elements than I should have
<td></td><td></td><td colSpan="3"></td><td></td><td colSpan="6"></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>
Edited to provide more information