Subject: [xsl] error in javascript, that is generated from xsl From: "Shailesh Valvaikar" <shailesh_valvaikar@xxxxxxxxx> Date: Wed, 6 Mar 2002 22:16:49 +0530 |
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"> "<xsl:value-of select="."/>" </xsl:for-each> <![CDATA[)" 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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Understanding Conditional, G. Ken Holman | Thread | Re: [xsl] error in javascript, that, Thomas B. Passin |
Re: [xsl] Understanding Conditional, G. Ken Holman | Date | RE: [xsl] RFC XSLT Standard - "Furt, Chris Bayes |
Month |