You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
Thanks for reporting the issue. For now, I'm fixing the interactive tests, but there's another bug that this issue helped me to understand.
The way this library works (and it's the exact way I've inherited it) is:
For each <xsl:apply-templates> found, runs all the <xsl:template> from the document until it is able to find one that brings child nodes from <xsl:apply-templates>;
Each call to <xsl:template> will try to rematch nodes;
<xsl:apply-templates> selects <element> node. When called, <xsl:template match="page/message"> tries to select nodes starting by <element>, because the path is relative. Not finding any nodes, it returns an empty string.
There are many aspects I'll have to rewrite in this library, and this one should take me some time to resolve, since it's (very) likely I'm having to rewrite the entire XPath mechanism to calculate priorities correctly. Other aspect is about default implemented implicit default templates, as described here: https://stackoverflow.com/a/1976910/1314276
I'll keep this issue open as a reminder of what needs to be fixed and/or reimplemented.
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:
Even when fixing all obvious errors in the code, like so:
output
with the given XML and XSLT is''
, which is wrong.The text was updated successfully, but these errors were encountered: