Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 27th, 2007, 12:12 PM
Registered User
 
Join Date: Jun 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Dynamically generating Javascript (XSLT in IE6)

Hi,

I'm having a problem with dynamically generating javascript code through XSLT in IE6. I'm getting the XML using XMLHttpRequest and using the Sarissa library to transform the XML. The resulting XML contains many script tags. But, IE doesnt seem to execute any javascript code in these, although normal HTML is generated fine. The thing works fine in Firefox.

What could be the problem?

Browser: IE6 on Windows 2000

The XSL file:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<h1>Hello World</h1>
<script type="text/javascript">
    alert('hello world');
</script>
</xsl:template>
</xsl:stylesheet>

(The above XSL never ever shows the alert)

Thanks
 
Old June 28th, 2007, 01:07 PM
Registered User
 
Join Date: Jun 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The observations and solution to the above problem are:
After calling

domFragment=xsltProcessor.transformToFragment(xmlD ata,document)

the resulting dom fragment was inserted (appendChild()) into a 'span' node in the document. But, IE did not insert the <script> nodes. Instead, it made an array of all the script nodes in domFragment.scripts.

Hence, all the elements of domFragment.scripts also had to be inserted after domFragment was inserted. This solved the problem. The same thing was observed even in IE7






Similar Threads
Thread Thread Starter Forum Replies Last Post
dynamically generating Excel file sunitapandey Struts 3 November 23rd, 2006 03:53 AM
Generating ViewState Names Dynamically rfinks VB How-To 3 July 31st, 2006 11:47 AM
Dynamically Generating Textboxes Maxood PHP How-To 6 March 9th, 2006 09:14 AM
Generating html tags dynamically sachin lad Servlets 1 April 26th, 2005 05:35 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.