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]

Copying Java expressions verbatim without character escaping?


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
   <if>
      <expr><![CDATA[a==1 && b==2 || c<3]]></expr>
      ...
   </if>

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/>
   ...
</xsl:template>

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?

Mike.

---
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


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