Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CDATA bug in XMLType

Status
Not open for further replies.

MikeAJ

Programmer
May 22, 2002
108
0
0
US
Hi, I'm using Oracle's XMLTYPE to retrieve an XML doc, an XSL doc, and then transform the XML using the XSL.
Code:
      v_web_xml := get_web_xml('en-US', TRUE);
      v_web_xsl := get_web_xsl('MODELPAGE');
      v_html    := v_web_xml.transform(v_web_xsl);

Here's a snippet from my xsl:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version = "1.0" 
                xmlns:xsl = "[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform"[/URL]
                xmlns:math="[URL unfurl="true"]http://www.exslt.org/math"[/URL]
                exclude-result-prefixes="math"
                disable-output-escaping="yes">
                
<xsl:output method = "html" indent = "no"/>
<xsl:strip-space elements = "*"/>
<xsl:preserve-space elements = "sp"/> 

<xsl:template match = "/*">
<script type="text/javascript"><![CDATA[
function getOLs() {
   if(typeof window.onload=='function'){ 
      if(typeof ol_ol=='undefined')ol_ol=new Array(); 
      ol_ol.push(window.onload);
   }
}

getOLs();
...
 ]]></script>

The tranformation seems to completely ignore the CDATA section, and it escapes it anyway. Here's the output:
Code:
<script type="text/javascript">
function getOLs() {
   if(typeof window.onload==&apos;function&apos;){ // test to see if onload has been set
      if(typeof ol_ol==&apos;undefined&apos;)ol_ol=new Array(); // test if array variable already exists
      ol_ol.push(window.onload); // this captures any previous onload function
   }
}

getOLs();

Is this a bug with Oracle, or is there something I can do to preserve the javascript?

Thanks for the help!
 
I got it. I had to use this in my xsl:
Code:
<script type="text/javascript">
<xsl:comment>
<![CDATA[
function getOLs() {
   if(typeof window.onload=='function'){ 
      if(typeof ol_ol=='undefined')ol_ol=new Array(); 
      ol_ol.push(window.onload); 
   }
}
]]>
</xsl:comment>
</script>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top