...

View Full Version : Problem calling javascript output by xml/xsl transform



MattL920
08-17-2005, 07:10 PM
I have a page where part of the content is gotten by loading an xml file through javascript, then an xsl document used to transform that to html, then document.write-ing that resulting html, like:


function loadXML(url){
var xml = new ActiveXObject("Microsoft.XMLDOM");
var xsl = new ActiveXObject("Microsoft.XMLDOM");
xsl.async = false;
xsl.load('the_xsl_file.xsl');
xml.onreadystatechange = function () {
if (xml.readyState == 4) document.write(xml.transformNode(xsl));
};
xml.load(url);
}

Part of the output of the xml-xsl transform are <script> tags with calls to some javascript functions inside them. The problem I'm having is that when I open this page locally just to test it out, everything works fine, and the code inside the <script> tags output by xsl get called like they're supposed to. But when I put it up on a web server to test it out, none of that code gets called and my page breaks.

I can't figure out what's preventing that from being called when it's on the web but doesn't prevent it when I open it locally. I'd really appreciate help on this.

thanks.

MattL920
08-18-2005, 03:03 PM
Just bumping this up... I could really use some help on this

thanks

hemebond
08-18-2005, 11:16 PM
We need access to all your code.

MattL920
08-22-2005, 09:20 PM
ok I've narrowed down what the problem is...

I'm loading an xml and xsl file with javascript in my page, then writing the transformation output to the page:


function loadXML(url){
var xml = new ActiveXObject("Microsoft.XMLDOM");
var xsl = new ActiveXObject("Microsoft.XMLDOM");
xsl.async = false;
xsl.load('the_xsl_file.xsl');
xml.onreadystatechange = function () {
if (xml.readyState == 4) document.write(xml.transformNode(xsl));
};
xml.load(url);
}

I'm calling that function within the <body>, after having also loaded an external .js file in the <head>. Part of the html that the transformation outputs are script tags that depend on what's in the external file.

Here's the problem: when I open the file locally everything works fine, the output fills the <body> with what I want, and the functions defined in the external script file get called. But when I put it up on the web (one of my company's development servers) the xml/xsl output looks like it's completely overwriting everything else in the page, including where I load the other javascript file, so it can't find it when I try and call its functions.

So then my question is why is it overwriting everything else in my page and how can I stop it from doing this?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum