1

我正在尝试运行一个空的简单代码片段来测试 Windows 10 上 NodeJs v8.11.1 上的 SaxonJS 1.1.0。

require('./Saxon-JS-1.1.0/SaxonJS.js');

但我收到了这个错误:

PS C:\XXX\sandbox\xsl-transformation> node main.js
C:\XXX\xsl-transformation\Saxon-JS-1.1.0\SaxonJS.js:17136
        setPlatform(JSTestDriver.platform);
                    ^
ReferenceError: JSTestDriver is not defined
at initialize (C:\XXX\sandbox\xsl-transformation\Saxon-JS-1.1.0\SaxonJS.js:17136:25)

查看源代码,我可以看到:

function initialize() {
    "use strict";
    if (inBrowser) {
        setPlatform(BrowserPlatform.platform);
        saxonPrint("Saxon-JS " + getProcessorInfo().productVersion + " in browser", 0);
    } else {
        // Currently only Nashorn. (Later need to distinguish from Node case)
        // Nashorn JSTestDriver
        setPlatform(JSTestDriver.platform);
        saxonPrint("Saxon-JS " + getProcessorInfo().productVersion + " in 
   Nashorn");

        // node NodePlatform
    }

    if (typeof platform.initialize === "function") {
        platform.initialize();
    }
}

似乎节点平台没有实现。

但是,在文档中,它是这样写的:

我们在这里主要讨论的是在浏览器中运行 Saxon-JS。但是,它也能够在 Node.js 等服务器端 JavaScript 环境中运行(此版本尚未完全支持)。

我深入搜索了 SaxonJS/NodeJS 的代码片段,但没有找到。有没有人在 NodeJS 上工作的 SaxonJS 的代码片段?

4

1 回答 1

1

恐怕文件有点过火了。我们确实有用户报告说让代码在 Node.js 下运行,我们自己“在实验室”完成了它,但它需要对已发布产品的源代码进行调整。发布后,代码在浏览器平台和 Nashorn 两个平台下运行(在 Nashorn 下,它假定我们的测试工具尚未发布)。

我们正在为 Node.js 开发一个版本。作为产品正确执行此操作需要浏览器版本中没有的许多功能,例如 XML 解析和序列化、调试支持、命令行接口和 API 等。

于 2018-06-27T11:06:21.843 回答