xslt-processor
xslt-processor copied to clipboard
Interactive test is broken
When opening the usage example and executing the transformation in the browser (Chrome), no result is shown and instead the following error message appears in the console:
Uncaught SyntaxError: await is only valid in async functions and the top level bodies of modules
at xslt.html:18
Uncaught ReferenceError: cleanxml is not defined
at onload (xslt.html:34:29)
Even when fixing all obvious errors in the code, like so:
function el(id) {
return document.getElementById(id);
}
function test_xslt() {
const xmlParser = new globalThis.XsltProcessor.XmlParser();
const xml = xmlParser.xmlParse(el('xml').value);
const xslt = xmlParser.xmlParse(el('xslt').value);
const xsltProcessor = new globalThis.XsltProcessor.Xslt();
xsltProcessor.xsltProcess(xml, xslt).then(output => {
console.log(output);
el('html').value = output;
el('htmldisplay').innerHTML = output;
});
}
function cleanxml() {
cleanvalue('xml');
cleanvalue('xslt');
}
function cleanvalue(id) {
const x = el(id);
x.value = x.value.replace(/^\s*/, '').replace(/\n\s*/g, '\n');
}
output with the given XML and XSLT is '', which is wrong.