[xsl] Re: XSL - Javascript problem

Subject: [xsl] Re: XSL - Javascript problem
From: "Annelies Vercruysse" <kontant@xxxxxxxxxxx>
Date: Thu, 25 Oct 2001 10:29:48 +0200
Can you show us your stylesheet?

Hi Oleg & xsl-List members, Thanx for your swift reply! Below you will find my stylesheets, these are shortened versions but with the functionality that I need. Normally the onLoadBody() must be executed but Netscape 6.1 gives the "Error: onLoadBody() is not defined" in the Javascript Console.


greetz, Annelies Vercruysse

XSL:----------------------------------------------------------------

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:template match="/">


 <html>
 <head>
 <title>Test page with javascript code</title>

 <script type="text/javascript">
 function onloadBody() {
    alert('When you see this, javascript works!');
 }
 </script>

</head>

 <body onload="onloadBody();">
   <table border="1">
     <tr>
       <th>Title</th>
       <th>Artist</th>
     </tr>
     <xsl:for-each select="CATALOG/CD">
     <tr>
       <td><xsl:value-of select="TITLE" /></td>
       <td><xsl:value-of select="ARTIST" /></td>
     </tr>
     </xsl:for-each>
   </table>
 </body>

</html>

</xsl:template>
</xsl:stylesheet>
--------------------------------------------------------------------
XML:----------------------------------------------------------------

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<CATALOG>
 <CD>
   <TITLE>Hide your heart</TITLE>
   <ARTIST>Bonnie Tyler</ARTIST>
 </CD>
 <CD>
   <TITLE>Greatest Hits</TITLE>
   <ARTIST>Dolly Parton</ARTIST>
 </CD>
 <CD>
   <TITLE>Still got the blues</TITLE>
   <ARTIST>Gary Moore</ARTIST>
 </CD>
</CATALOG>
--------------------------------------------------------------------
--------------------------------------------------------------------

Original Request:

My current HTML pages contain Javascripts that treat elements in the HTML document.
> (getElementById();)
>
> It seems that these javascripts are completely ignored when opening the XML page. Could it be that an XML page doesn't have the
> "document"-property so an element will never be found?
>
> I've already tried to put the javascript between the following tags:
> <![CDATA[ .... ]]>
>
> (I use the Netscape 6.1 browser)
>
> are there any known bugs with Javascripts within XSL?
> can anyone please help me? It would very much be appreciated!


From my experience with mozilla's xslt I remember there were some problems
with script invocation in generated on the fly html documents, but I remember there were

some workarounds too. Can you show us your stylesheet?

- --
Oleg Tkachenko
Multiconn International, Israel



_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp


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



Current Thread