пример для msxml - ActiveXObject доступен только в IE, в Chrome с использованием собственных методов:
import * as ts from "typescript";
...
private loadMsXml(src: string): any {
let code: string = `({
Run: (data: string): any => {
let doc = new ActiveXObject("Msxml2.DOMDocument.6.0");
doc.async = false;
doc.loadXML(data);
return doc;
})`;
const e = eval;
let result = ts.transpile(code);
let runnalbe: any = e(result);
return runnalbe.Run(src);
}
private transformXml(xmlDoc: any, xsltDoc: any): string {
if (this.isBrowserIE()) {
let xmlDocMS = this.loadMsXml(new XMLSerializer().serializeToString(xmlDoc));
let xslDocMS = this.loadMsXml(new XMLSerializer().serializeToString(xsltDoc));
let resultXml = xmlDocMS.transformNode(xslDocMS);
return resultXml;
}
let xsltProcessor = new XSLTProcessor();
xsltProcessor.importStylesheet(xsltDoc);
let resultDoc = xsltProcessor.transformToDocument(xmlDoc);
let resultXml = new XMLSerializer().serializeToString(resultDoc);
return resultXml;
}