Uncaught TypeError: this.al is not a function in today’s XPathle when using the “use stats“ button
If you go to https://gimsieke.github.io/xpathle/#daily_2022-08-26 and push the “use stats” button and then hit Enter or push “Submit“, an error “Uncaught TypeError: this.al is not a function” is thrown. I’ve changed the JS to SaxonJS2.js in order to facilitate debugging.
The same error occurs if you reduce the evaluated XPath expression to
Updated by Martin Honnen 3 months ago
I tried to isolate the bug but couldn't so far, a simple XPath evaluation like
//*/name()[ancestor-or-self::*] gives a clear error like e.g.
Context item for ancestor-or-self axis is not a node - supplied:xs:string('html') instead of that crash where the code seems to look for an axis evaluation on a non-node.
Updated by Norm Tovey-Walsh 2 months ago
- Status changed from AwaitingInfo to Resolved
- Applies to JS Branch Trunk added
- Fix Committed on JS Branch 2, Trunk added
It turned out to be a very simple error in the construction of the diagnostic data for the error message. The code was trying to find the axis name by calling
this.axisName(operand) which failed because (a)
this was the Window object and (b) the only
axisName method resolves to a simple lookup anyway. So I replaced it with
Expr.axisNames()[operand] and it works.
I decided that it wasn't practical to try to whittle the complex XPathle stylesheet down to a simple test case, so there are no new tests for this fix :-(
I did explicitly test the fix on both the
Gerrit, near as I can tell, you still need to put in a
xsl:try or something. The stylesheet fails because you're attempting to do an axis operation when the context item is a string. But it doesn't crash the SaxonJS runtime anymore.
Please register to edit this issue