[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

error in javascript, that is generated from xsl

Subject: error in javascript, that is generated from xsl
From: "Shailesh Valvaikar" <shailesh_valvaikar@xxxxxxxxx>
Date: Wed, 6 Mar 2002 22:16:49 +0530
javascript appendchild error
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.