xsl-list
[Top] [All Lists]

Re: [xsl] A Problem with Variables and Xpath

2011-07-25 16:51:44

I have a variable like this:

<xsl:variable name="foo">something</xsl:variable>

and I am trying to set an attribute in this way:

<disney>
   <xsl:attribute name="mickey">
    <xsl:value-of select="./$foo"/>
   </xsl:attribute>
</disney>

where $foo is the name of an attribute of the source document.

The (wrong) output is:

<disney mickey="something">
</disney>
It's actually the correct output - it's your expectations that are wrong. Variables in XPath hold values, they don't hold bits of expression text. XPath is not a macro language. select="./$foo" means exactly the same as select="$foo" - it returns the value of the variable $foo.

Michael Kay
Saxonica


while the desired one is:

<disney mickey="valueof(something)">
</disney>

Thanks for help!

Christian

P.S.
I am using XSLT and Xpath 2.0

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