[xsl] Copying Java expressions verbatim without character escaping?

Subject: [xsl] Copying Java expressions verbatim without character escaping?
From: Michael Ody <Michael.Ody@xxxxxxxxxxxx>
Date: Wed, 20 Jun 2001 10:53:09 +0100
I'm using XSLT to create .jsp files which are mostly HTML but with a little
JSP code dotted about in them.  I want to copy a logical expression
verbatim from my source XML to my output JSP, but I'm having problems if the
expression contains ampersands, less-than or greater-than symbols.  Here's
an example...

The XML document contains things like
      <expr><![CDATA[a==1 && b==2 || c<3]]></expr>

I want this to become (omitting the <% and %> tags)
   if (a==1 && b==2 || c<3) {

Here's the XSLT I've got at the moment:
<xsl:template match="if">
   <xsl:text/> if ( <xsl:value-of disable-output-escaping="yes"
select="expr"/> ) { <xsl:text/>

Notwithstanding the d-o-e attribute, the output of this is
   if (a==1 &amp;&amp; b==2 || c&lt;3) {

which obviously is not valid Java!

[Notes: The stylesheet has an output method of 'html'.  I'm using Xalan to
perform the transformation.  The JSP file is being created by means of the
<xalan:write> element.]

So my question is how to prevent special characters being escaped during the
copy from XML to JSP?


Signal Computing Ltd.       20 Nugent Road, The Surrey Research Park,
http://www.signal.co.uk     Guildford, Surrey GU2 7DF, UK
Tel: +44(0)1483 579900    Fax: +44(0)1483 562836
Registered in London, No. 1672944

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread