You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Scott Moore <sm...@novacoxmail.com> on 2001/10/11 14:53:14 UTC
Using parameters
I have a general XSLT question, not really specific to just Xalan. I'm creating XSL-FO tables and I would like to generalize the table creation with a XSLT template. But I'm having problems with the selection of child nodes that go into the columns of the table.
For instance
<xsl:call-template name="table-body">
<xsl:with-param name="root" select="/root/TableData"></xsl:with-param>
<xsl:with-param name="col1-select" select="'year'"/>
</xsl:call-template>
This calls by table creation template. The "col1-select" is the name of the node underneath the /root/TableData node whose value I want placed into the table.
Here's the template to create the table:
<xsl:template name="table-body">
<xsl:param name="root"/>
<xsl:param name="col1-select"/>
<fo:table-body>
<xsl:for-each select="$root">
<fo:table-row>
<fo:table-cell>
<fo:block xsl:use-attribute-sets="table-body"><xsl:value-of select="$col1-select"/></fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
</fo:table-body>
</xsl:template>
The xsl:for-each works fine and loops thru all the data. The problem is I can't select the child nodes values underneath $root unless I hardcode the values (e.g., if I change $col1-select to "year", it works as expected). Is there any way I can use a variable to select the child nodes I'm interested in using when producing my table?
I've tried {$col1-select} and that doesn't work either. Neither does "./$col1-select" or "./{$col1-select}".
Any help would be most appreciated!
Thanks,
Scott