[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|