我在尝试SaxonJS
使用webpack
. 据我所知,webpack
视图SaxonJS
只是另一个模块,而SaxonJS
不是一个AMD
或CommonJS
模块。相反,Big.js
(SaxonJS
依赖项)劫持了导出。我相信修复 Node.js 支持也会解决这个问题。
import * as SaxonJS from "./Saxon-JS/SaxonJS.js";
export class Transformer {
public static transform(inputStr: string, sefFile: string, cb: Function) {
// wrap the JSON in XML, as required by XSLT transform
let wrappedJson = `<root xmlns="http://www.w3.org/2005/xpath-functions">${inputStr}</root>`;
SaxonJS.transform({
sourceText: wrappedJson,
stylesheetLocation: `xslt/${sefFile}`,
initialTemplate: "start",
destination: "application"
}, cb);
};
}
请注意,这是一个网络场景;SaxonJS 正在被浏览器调用。