Hi Scott. Your <xsl:value-of select="$col1-select"/> is simply selecting
the string value of the variable reference, as it is supposed to do.
> I've tried lots of different expressions
>
> "{$col1-select}"
Only attributes specified in the XSLT specification as attribute value
templates will accept {xxx}. select and test attributes are not among
them. The bottom line is that XPath expressions can not be dynamically
evaluated.
Probably your best bet is:
<xsl:value-of select="*[name() = $col1-select"/>
-scott
Scott Moore
<[EMAIL PROTECTED] To: "Xalan-J-Users (E-mail)"
<[EMAIL PROTECTED]>
ecide.com> cc: (bcc: Scott Boag/CAM/Lotus)
Subject: Help! Using variables
in for-each
11/02/2001 12:35
PM
I'm trying to write a template in xalan that takes a result tree fragment
($root) along with the names of child elements ($col1-select and
$col2-select). This template would then dynamically create a XSL-FO table
based on the variables passed in. The template looks something like this:
<xsl:template name="table-body">
<xsl:param name="root"/>
<xsl:param name="col1-select"/>
<xsl:param name="col2-select"/>
<fo:table-body>
<xsl:for-each select="$root">
<fo:table-row>
<fo:table-cell>
<fo:block><xsl:value-of select="$col1-select"/></fo:block>
</fo:table-cell>
<xsl:if test="string-length($col2-select) > 0">
<fo:table-cell>
<fo:block><xsl:value-of select="$col2-select"/></fo:block>
</fo:table-cell>
</xsl:if>
</fo:table-row>
</xsl:for-each>
</fo:table-body>
</xsl:template>
<xsl:call-template name="table-body">
<xsl:with-param name="root" select="/Session/Values"></xsl:with-param>
<xsl:with-param name="col1-select">node1</xsl:with-param>
<xsl:with-param name="col2-select">node2</xsl:with-param>
</xsl:call-template>
It doesn't work. Instead of treating $col1-select as a XPath expression,
it
just adds the literal string. I've tried lots of different expressions
"{$col1-select}"
"./$col1-select"
"self:node()/[name()=$col1-select]"
blah blah
Is this possible? I think it's probably something simple, but I just can't
figure it out.
Thanks for any help,
Scott