This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Adding HTML Data Into XSL File


> 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>&lt;img src="/somepaththat/isvalid/a.gif"&gt;</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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]