xsl-list
[Top] [All Lists]

RE: passing a node name as a param and then using it

2004-06-16 15:50:49
It's a little frustrating when people come to this list and ask the same
question as two other people have asked (and had answered) in the last 24
hours. It's good practice to listen in to a list for a couple of days before
asking your questions.

The answer is: to construct an XPath expression from a string built at
run-time, you need the xx:evaluate() extension, which is only available in a
few products (e.g. Saxon and Xalan). However, many cases where people think
they need this capability can be handled using

select="*[name()=$x]"

Michael Kay 

-----Original Message-----
From: Mike Kellstrand [mailto:kellstrand(_at_)yahoo(_dot_)com] 
Sent: 16 June 2004 18:29
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] passing a node name as a param and then using it

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]
 
How do I get this to work as intended?
 
Thanks,  Mike


              
__________________________________
Do you Yahoo!?
Take Yahoo! Mail with you! Get it on your mobile phone.
http://mobile.yahoo.com/maildemo 

--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--





<Prev in Thread] Current Thread [Next in Thread>