[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Copying Java expressions verbatim without character es

Subject: Copying Java expressions verbatim without character escaping?
From: Michael Ody <Michael.Ody@xxxxxxxxxxxx>
Date: Wed, 20 Jun 2001 10:53:09 +0100
michael ody
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.