Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

successor of msxsl.exe?

Tags:

xslt

msxsl

msxml6

We intend to migrate our framework from msxml4 to msxml6. We where using msxsl.exe as yet. It seems to support only MSXML versions up to 4.0, as command line msxsl.exe -u version 6.0 tells me. Is there a successor of msxsl.exe? Any alternative command line processor?

like image 423
Matthias Doringer Avatar asked Jan 13 '10 16:01

Matthias Doringer


1 Answers

There are a number of ways you could replace the existing processor, it just depends on what level of functionality you require and whether you need MSXML specific functionality. For example there is xsltproc which is part of libxslt (can get some windows binaries from here for example). This page gives you a quick replacement in C# but both change the command line usage and might not implement the same MSXML extensions (xsltproc certainly doesn't).

If you are just interested in a simple command line processor which uses MSXML 6 then you could do worse than using a simple JScript application. Save the following code as xsltr.js and run as cscript xsltr.js input.xml template.xsl output.txt:

var adTypeBinary = 1;
var adSaveCreateOverWrite = 2;
var adSaveCreateNotExist = 1;

try
{
    var args = WScript.Arguments;

    if(args.length < 3)
    {
        WScript.Echo("Usage: xsltr.js file.xml file.xsl output.txt");
        WScript.Quit(1);
    }
    else
    {
        var xml = args(0);
        var xsl = args(1);
        var out = args(2);

        var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.6.0");
        var xslDoc = new ActiveXObject("Msxml2.DOMDocument.6.0");

        /* Create a binary IStream */
        var outDoc = new ActiveXObject("ADODB.Stream");
        outDoc.type = adTypeBinary;
        outDoc.open();

        if(xmlDoc.load(xml) == false)
        {
            throw new Error("Could not load XML document: " + xmlDoc.parseError.reason);
        }

        if(xslDoc.load(xsl) == false)
        {
            throw new Error("Could not load XSL document: " + xslDoc.parseError.reason);
        }

        xmlDoc.transformNodeToObject(xslDoc, outDoc);
        outDoc.SaveToFile(out, adSaveCreateOverWrite);
    }
}
catch(e)
{
    WScript.Echo(e.message);
    WScript.Quit(1);
}

Still is there is a rationale you cannot use msxsl? Version 4.0 of MSXML has never been a standard installation so you would have always had to install it manually (though I think it came with Office at one point). Could you not deploy version 4 on the machines you need to do the processing on?

like image 196
tyranid Avatar answered Oct 24 '22 17:10

tyranid