tags:

views:

35

answers:

2

Hi all, I have declared one variable in xslt, assigned some value to it but while retrieving the value I am facing some problem.

                 <xslt:variable name="Msg">
                 Hello for more info <a href="http://someurl/"&gt;click me.</a>
                </xslt:variable>

while retrieving the value the content is coming as plain text means Click me is not coming as link.should I change my approach for that link or Something is wrong from my end. Thanks.

+1  A: 

EDIT:

Are you using <xsl:copy-of select="$Msg"/> when outputting the value? Otherwise the tags will not be output properly, also check the output method is set to HTML:

<xslt:output method="html" version="1.0" encoding="ISO-8859-1" indent="yes"/>
James
no it will not work, it will print <a href="http://someurl/" also, which i dont want
Wondering
EDIT: See comments above
James
nope.still not working..I think I need to show the link in some other way....
Wondering
Can you show us the code you use to actually select the value of the variable?
Jakob
Copy-of worked for me..Thanks for ur time and help.+1 for u :-)
Wondering
+1  A: 

From the sound of it, you're currently using <xsl:value-of select="$Msg"/> to obtain the variable's contents. Instead, try using <xsl:copy-of select="$Msg"/>.

Jakob
yes, it worked for me..thanks for ur help.<xsl:copy-of also selects the attribute, which i didnt know.
Wondering
For future reference, here's a rundown on different ways to select values in XSLT: `value-of` converts any given value to a string, `copy-of` makes an exact copy of a node, and `apply-templates` applies any matching templates to the value. Due to a part of the XSLT 1.0 spec that was removed in 2.0, however, unless the variable's contents are obtained through the variable's `select` attribute, you can't use `apply-templates` on it. In those cases (including this one), `copy-of` is your best bet.
Jakob