Mike Kellstrand wrote:
I want to be able to pass a node name into a named template as a param and
then operate on it. When I try to use the node name param in the template,
it gets interpreted as a string and not an actual node. i.e.
The snipett:
<xsl:variable name="x" select="choice"/>
<fo:block>a: <xsl:value-of select="choice[1]"/></fo:block>
<fo:block>b: <xsl:value-of select="concat($x,'[1]')"/></fo:block>
Will generate:
a: {the actual xml data in the 1st choice node}
b: choice[1]
That's exactly as it is supposed to work. Actually this is an XSLT question, only loosely related to FOP, and would have better been asked on the XSL list: http://www.mulberrytech.com/xsl/xsl-list/
Anyway: You expect the XSLT processor to perform what's called double evaluation: first evaluate "concat($x,'[1]')" into "choice[1]", then evaluate the latter again. That's not the way XPath expressions are handled.
How do I get this to work as intended?
Commonly, two approaches: 1. Use <fo:block>b: <xsl:value-of select="*[name()=$x][1]"/></fo:block> Note that this approach works for your specific problem but wont help you in more general cases. 2. Most XSLT processors have an extension function which evaluatess a string as XPath expression, roughly like <fo:block>b: <xsl:value-of select="foo:evaluate(concat($x,'[1]'))"/>.. The exact function name and the necessary namespace are processor specific, check your processor's manual for details.
J.Pietschmann
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
