I'm trying to have a script automatically transform an xml file into several html files using different xslt style sheets. However, whatever I try, I get errors. I've tried it in both VBscript and JScript, and both give me errors. The xml file is 537 KB, and the xsl file is 5 KB.
Here's iteration 1 in JScript. This script works for one of my style sheets (a style sheet that creates a smaller html file), but on a stylesheet that creates a bigger html file, it gives me an "invalid procedure call or argument" on outstr (as if outstr didn't return properly) error :
var xsl = new ActiveXObject("MSXML2.DomDocument.6.0");
xsl.async = false;
var boolval = xsl.load("../Commands/commands.xsl");
if(!boolval)
{
WScript.Echo("XSL load error");
WScript.Quit();
}
var xml = new ActiveXObject("MSXML2.DomDocument.6.0");
xml.async = false;
boolval = xml.load("../Commands/commands.xml")
if(!boolval)
{
WScript.Echo ("XML load error " );
WScript.Quit();
}
var fso = new ActiveXObject("Scripting.FileSystemObject");
var outstr = xml.transformNode(xsl);
var ofl = fso.CreateTextFile("../Commands/commands.html", true, false);
ofl.Write (outstr);
ofl.Close();
So here's iteration 2, using the transformNodeToObject method instead. In this case, I get an "Unspecified error" code 80004005 in msxml6.dll:
var xsl = new ActiveXObject("MSXML2.DomDocument.6.0");
xsl.async = false;
var boolval = xsl.load("../Commands/commands.xsl");
if(!boolval)
{
WScript.Echo("XSL load error");
WScript.Quit();
}
var xml = new ActiveXObject("MSXML2.DomDocument.6.0");
xml.async = false;
boolval = xml.load("../Commands/commands.xml")
if(!boolval)
{
WScript.Echo ("XML load error " );
WScript.Quit();
}
var result = new ActiveXObject("MSXML2.DomDocument.6.0");
xml.transformNodeToObject(xsl, result);
result.save("../Commands/commands.html");
My intuition says that the processor just can't handle creating a file that big. Is this right, or am I doing something wrong. If it's just a size issue, is there some other library/object I can use in vbscript/jscript that will get the job done?