RE: XSL, Javascript

Subject: RE: XSL, Javascript
From: Heather Lindsay <heather.lindsay@xxxxxxxxxxxxx>
Date: Mon, 31 Jul 2000 13:10:22 -0400
	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[');


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

<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" />');


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

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,

 XSL-List info and archive:

Current Thread