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

Re: The case of the mysteriously corrupted XSL transf

Subject: Re: The case of the mysteriously corrupted XSL transformation (ARRGH)
From: Anton Triest <anton@xxxxxxxx>
Date: Thu, 02 Dec 2004 21:46:50 +0100
document.write is not a function
Hi Wong,

I made a simple testcase, that demonstrates Mozilla/Gecko/Transformiix does have a problem with javascript document.write:

=== test.xsl ===

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
 xmlns="http://www.w3.org/1999/xhtml"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 >
 <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"
   doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
   doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
   />
 <xsl:template match="/">
   <html>
     <head><title>test</title></head>
     <body>
       <div>
         <script type="text/javascript">
           document.write('hello');
         </script>
       </div>
     </body>
   </html>
 </xsl:template>
</xsl:stylesheet>

=== input.xml ===

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<dummy/>

=== saxon output.html ===

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
   <title>test</title>
 </head>
 <body>
   <div>
     <script type="text/javascript">
       document.write('hello');
     </script>
   </div>
 </body>
</html>

The output.html generated by Saxon works fine in IE6 and Moz (browser says 'hello').

Opening input.xml (ie. transforming via the xml-stylesheet PI) works fine in IE6 too, but not in Firefox: blank page, and javascript error: "document.write is not a function".

(Firefox 1.0 and Netscape 7.2 show the same result)

I don't know if this is "normal", or a Mozilla/Gecko bug... I think it should work - I have used methods like appendChild succesfully, why should document.write fail here? Maybe some other xslister can elaborate...

Best regards,
Anton




Wong Chin Shin wrote:


Hi Anton,

Thanks for the help.

I see what you mean, but can I clarify:

Is it true that "on-the-fly" Javascript like document.write will have
problems working in an XSL-transformed page? I had the impression that the
transformation layer is just an additional layer and that the browser would
consider the final code only. If this is the case, a lot of existing scripts
would be off-limits to whoever's trying to employ this technique.

Also, the fact that it works using some XSL parsers and not with others is a
worry. I just hope that I'm doing things according to specs so far and the
next server upgrade won't break it.

Thanks!
Wong

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.