RE: [xsl] error in javascript, that is generated from xsl

Subject: RE: [xsl] error in javascript, that is generated from xsl
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Wed, 6 Mar 2002 17:21:42 -0000
I note that one line of your code reads
		<![CDATA[)&quot;
Using an entity reference within a CDATA section looks wrong.

If you're playing this kind of game you need to look at the HTML that your
stylesheet is generating before you throw it at the browser. Debugging it
directly in IE is going to be really hard work.

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Shailesh
> Valvaikar
> Sent: 06 March 2002 16:47
> To: xsllist
> Subject: [xsl] error in javascript, that is generated from xsl
>
>
> Hello,
>
> I have an xml that has 'row', 'column' kinds elements.
> I want to select all the data in the 'col' elements and show
> the data in
> html
> tables. But I want to show only a few at a time.
>
> For this, I read the data into a javascript array and then make
> manipulations over that
> array.
> I have specified an xsl stylesheet with the xml file.
> If I see the javascript code the way it would have been generated
> (transformed)
> it works fine in IE 5.5, but when I try generate the same
> using an xsl, it
> gives an error.
>
> I have included the javascript code in a  CDATA section.
> The errors are at the places where there are '>' and '<' in
> the script. This
> should not
> happen when the javascript code is in CDATA section.
> Can anybody point out the problem ?
>
> I have tried the same with Netscape 6. This gives no error
> and no output!
>
> Here is the xsl file.
> ---------------------------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
>
> 		<xsl:template match="/">
> 		<HTML>
> 		<HEAD><TITLE>Transformed data from row-col xml</TITLE>
> 		<SCRIPT language="Javascript">
> 					<![CDATA[
>
> 					    var current;
> 					    function displayTable(incr)
> 					    {
> 					        current =
> current + incr;
> 					        if(current > 4)
> 					            current =
> 4; /* reset the current if it exceeds the min-max
> values */
> 					        if(current < 0)
> 					            current = 0;
> 					        var
> tableData=new Array(]]>
> 					        <xsl:for-each
> select="column">
>
> &quot;<xsl:value-of select="."/>&quot;
> 					        </xsl:for-each>
> 					        <![CDATA[)&quot;
> 					        var
> mybody=document.getElementsByTagName("body").item(0);
> 					        var table =
> document.getElementsByTagName("TABLE").item(0);
> 					        mytable =
> document.createElement("TABLE");
> 					        mytablebody =
> document.createElement("TBODY");
> 					        for(j=current ;
>  j < 2+current; j++)
> 					        {
>
> mycurrent_row=document.createElement("TR");
> 					          for(i=0; i < 2; i++)
> 					          {
>
> mycurrent_cell=document.createElement("TD");
>
> currenttext=document.createTextNode(tableData[j*2 +
> i]);
>
> mycurrent_cell.appendChild(currenttext);
>
> mycurrent_row.appendChild(mycurrent_cell);
> 					           }
>
> mytablebody.appendChild(mycurrent_row);
> 					        }
>
>
> mytable.appendChild(mytablebody);
>
> mybody.appendChild(mytable);
>
> mytable.setAttribute("border","2");
> 					    }
>
> 					    function start()
> 					    {
> 					        current = 0;
> 					        displayTable(0);
> 					    }
> 					 ]]>
>
> 		</SCRIPT>
> 		</HEAD>
> 		<BODY onload="start()">
> 		<form>
> 		<button name="prev"
> onclick="displayTable(-2)">Prev</button>
> 		<button name="next"
> onclick="displayTable(+2)">Next</button>
> 		</form>
> 		</BODY>
> 		</HTML>
> 		</xsl:template>
>
> </xsl:stylesheet>
> -----------------------------------
> The xml looks somewhat like this ...
>
> <?xml version="1.0" encoding="UTF-8"?>
> <?xml-stylesheet type="text/xsl" href="table_style.xsl"?>
> <some_table>
> 	<row>
> 		<column>A</column>
> 		<column>B</column>
> 		<column>C</column>
> 		<column>D</column>
> 	</row>
> ...
>
> </some_table>
>
> Thanks in advance,
> Shailesh
>
>
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread