xsl-list
[Top] [All Lists]

RE: Reading value of passed variable

2004-06-17 12:12:00
I imagine it has more to do with the OP either not looking, or not 
understanding what they are looking for. Although the questions all looked the 
same to me (or others with some experience with xsl), it was only because I 
recognized it for what it was, the OPs probably didn't... It's like the 
difference between thinking about manipulating tags, or operating on a tree of 
nodes...

If you google for "xsl xpath variable" 3 out of the first 5 appear to be the 
same problem... the answer is also buried on the dpawson faq, but sometimes 
it's hard to find what you are looking for because there is so much there...

Josh

-----Original Message-----
From: Pieter Reint Siegers Kort 
[mailto:pieter(_dot_)siegers(_at_)elnorte(_dot_)com]
Sent: Thursday, June 17, 2004 6:09 AM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] Reading value of passed variable


It may be because there's no good FAQ about it? Or could it better be done
by Xpointer technology? Extensions are fine and show the goodwill of
implementors but they are not portable.

<prs/>

-----Original Message-----
From: Michael Kay [mailto:mhk(_at_)mhk(_dot_)me(_dot_)uk] 
Sent: Thursday, June 17, 2004 1:58 AM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] Reading value of passed variable

Wow, that's the fourth time this question has been asked in two days. Does
no-one lurk before posting questions nowadays?

Standard XSLT doesn't allow you to access variables in this way any more
than C or Java do. It's not an introspective language.

Some products (Saxon, Xalan) have an xx:evaluate extension that lets you do
it.

However, it's usually the wrong thing to do. If you have three variables a,
b and c and you don't know statically which one you want, then you should
probably have a single variable X whose value is an XML tree containing a,
b, and c as elements. You can then access the elements using standard path
expressions - including the dynamic form //*[name()=$var].

Michael Kay 

-----Original Message-----
From: Mayo [mailto:mayo(_at_)mayo(_dot_)sk]
Sent: 16 June 2004 23:32
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Reading value of passed variable

Hello,

I'm trying to read value of a variable who's name is passed to the 
xslt processor as argument.

My source file has something like:
<var name="$somevar"/>

The variable $xsltvar will be defined at the processor's runtime, so 
it has some value ("test" just for the sake of example - as if 
<xsl:variable name="somevar" select="'test'"/> was used). Now what I'm 
trying to do is to have xslt output the value of this variable.

I've tried using <value-of select=""> with selecting the name 
attribute from the var node, but to no avail.

<xsl:template match="var">
     <xsl:value-of select="@name"/>
</xsl:template>

This, naturally, prints out the name of the variable ("$somevar"), but 
I can't get the actual value of the variable.

any ideas?

Thanks,
Mayo


--+------------------------------------------------------------------
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>
--+--




--+------------------------------------------------------------------
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>
--+--

--+------------------------------------------------------------------
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>