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

RE: XSL, Javascript

Subject: RE: XSL, Javascript
From: Heather Lindsay <heather.lindsay@xxxxxxxxxxxxx>
Date: Mon, 31 Jul 2000 13:10:22 -0400
xsl javascript
hi,
	You could probably get away with not using the CDATA section.  I
don't use it in my code and it works just fine.  If you want to keep the
CDATA section then you have to end it before your XSL and then start it
again after the XSL code.  In other words:

<script language="Javascript"><![CDATA[
function selbox() {

var var1= window.document.formAirPort.listAirPort;
if(var1.value == 'xxx') {

document.write(']]><xsl:apply-templates select=".//locationx" /><!CDATA[');

}

if(var1.value == 'yyy') {

document.write(']]><xsl:apply-templates select=".//locationy" /><!CDATA[');

}
}
 ]]></script>


However you could just do the following and it will probably work just as
well:

<script language="Javascript">
function selbox() {

var var1= window.document.formAirPort.listAirPort;
if(var1.value == 'xxx') {

document.write('<xsl:apply-templates select=".//locationx" />');

}

if(var1.value == 'yyy') {

document.write('<xsl:apply-templates select=".//locationy" />');

}
}
</script>

When I had the same problem I found this explaination from Jeni Tennison to
be very helpful:

"The purpose of using the CDATA section in the stylesheet is to make life
easier for you so that you don't have to escape all those <s and &s and so
on.  The CDATA section in your stylesheet is simply marking out bits of the
information within the stylesheet that shouldn't be parsed as XML; using a
CDATA section in your stylesheet doesn't create a CDATA section in your
output.

So, to insert some stuff that *should* be interpreted as XML, you just
need to close the CDATA section, put in the element, and then open the
CDATA section again.

If there's very little escaping that you would have to do anyway, and lots
of information to be inserted into the script (which looks to be the case
from your example), then it might be simpler to get rid of the CDATA
section altogether."   - Jeni

	I hope this helps,
	Heather



 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.