This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Adding HTML Data Into XSL File
- From: "Michael Kay" <michael dot h dot kay at ntlworld dot com>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Wed, 3 Jul 2002 15:24:30 +0100
- Subject: RE: [xsl] Adding HTML Data Into XSL File
- Reply-to: xsl-list at lists dot mulberrytech dot com
> I have been directed to add a <img src="/somepathtoanimage">
> to the xsl. But the path needs to be dynamic (coming from a
> servlet parameter). So I created a <xsl:param name="image"
> select="'/defaultpath'" /> And when I do the transform, I try
> and put in a valid generated path, but it does not work. When
> I source the page, the browser shows the following:
>
> </table><img src="/somepaththat/isvalid/a.gif"></form>
>
> So it prints the above to the screen and not <img
> src="/somepaththat/isvalid/a.gif"> which would show the a.gif.
>
> Any ideas how to get around this?
>
You are passing in a string that contains markup. The XSLT processor
doesn't know that you want the "<" and ">" characters treated as markup,
so it escapes them.
There are two solutions.
(a) pass in a parsed XML document (e.g. a DOM) instead of a string.
(b) tell Xalan not to escape the special characters in the string by
using disable-output-escaping.
We usually discourage disable-output-escaping on this list, because it
can be greatly abused, but this is exactly the situation it is useful
for, when you want to include unparsed HTML directly into your
serialized output.
Michael Kay
Software AG
home: Michael.H.Kay@ntlworld.com
work: Michael.Kay@softwareag.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list