RE: [xsl] Can I put a variable to be interpreted in an xml node?

Subject: RE: [xsl] Can I put a variable to be interpreted in an xml node?
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Wed, 14 Jul 2004 09:28:49 +0100
> I'm new to this list, and this is my first question. I have a 
> two-lingual website (dutch & french). The texts are manually put in 
> a seperate XML file. Now in one case the text contains a 
> variable, like in this example:
> 
> <tagname><![CDATA[You can find the link <a 
> href="{$link}">here</a>]]></tagname>
> 
> Obviously when I pull this tag into the document using 
> <value-of the {$link} is not interpreted. How can I solve 
> this problem? 
> I need to use CDATA because the tag can contain html code 
> like bold, paragraph tags etc.

It's much better to use well-formed markup in the source document. By
putting tags in CDATA, you are telling the system "this isn't markup, it's
ordinary text", which patently isn't true, and has the effect that it makes
the internal structure inaccessible to the XPath and XSLT processors.

If you can't redesign the source document, then try to find a processor that
supports the disable-output-escaping option, and use <xsl:value-of with
disable-output-escaping="yes"/>. This is not a good solution, because it
means you rely on the result tree being serialized as part of the
transformation, but it may be your only escape route from a poor document
design.

Michael Kay

Current Thread