msxsl.exe 的继任者? [英] successor of msxsl.exe?

查看:23
本文介绍了msxsl.exe 的继任者?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们打算将我们的框架从 msxml4 迁移到 msxml6.我们在哪里使用 msxsl.exe 呢.它似乎只支持高达 4.0 的 MSXML 版本,作为命令行msxsl.exe -u 6.0 版告诉我.有没有 msxsl.exe 的后继者?任何替代的命令行处理器?

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?

推荐答案

您可以通过多种方式替换现有处理器,这取决于您需要什么级别的功能以及您是否需要 MSXML 特定功能.例如,xsltproc 是 libxslt 的一部分(可以从 此处 例如).页面为您提供了 C# 中的快速替换,但两者都更改了命令行用法并且可能不会实现相同的 MSXML 扩展(xsltproc 肯定不会).

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).

如果您只对使用 MSXML 6 的简单命令行处理器感兴趣,那么您可能会比使用简单的 JScript 应用程序做得更糟.将以下代码另存为 xsltr.js 并作为 cscript xsltr.js input.xml template.xsl output.txt 运行:

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);
}

还有理由不能使用 msxsl 吗?MSXML 4.0 版从来都不是标准安装,因此您总是必须手动安装它(尽管我认为它曾经与 Office 一起提供).您不能在需要进行处理的机器上部署第 4 版吗?

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?

这篇关于msxsl.exe 的继任者?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆