我正在尝试运行一个空的简单代码片段来测试 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 的代码片段?