node.js - Node.js 上的 SaxonJS
问题描述
我正在尝试运行一个空的简单代码片段来测试 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 的代码片段?
解决方案
恐怕文件有点过火了。我们确实有用户报告说让代码在 Node.js 下运行,我们自己“在实验室”完成了它,但它需要对已发布产品的源代码进行调整。发布后,代码在浏览器平台和 Nashorn 两个平台下运行(在 Nashorn 下,它假定我们的测试工具尚未发布)。
我们正在为 Node.js 开发一个版本。作为产品正确执行此操作需要浏览器版本中没有的许多功能,例如 XML 解析和序列化、调试支持、命令行接口和 API 等。
推荐阅读
- postgresql - 在文本中执行多个替换的更好功能,由数组指定?
- python - 在文本文件中查找和替换正则表达式(mac 地址)
- python - import pyzbar.pyzbar - 找不到 zbar 共享库
- node.js - 如何在 node express 中同时使变量在路由和模板中可用?
- sql - 分配上的 SQL 连接问题
- python - 如何从python中列表的特定索引开始循环?
- javascript - 有没有办法为制表器中的列标题获取鼠标悬停事件?
- javascript - Discord.js 为什么我的帮助命令不起作用?
- python - 如何将python文本字符串转换为List?
- go - 什么是正确的 ZMQ 模式?