Bug #5662
closedUncaught TypeError: this.al is not a function in today’s XPathle when using the “use stats“ button
100%
Description
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 //*/namespace-uri()
, //*/name()
, //*/local-name()
, or /descendant-or-self::*[40]/name()
.
Updated by Gerrit Imsieke about 2 years ago
This bug seems to be caused by this recent commit in XPathle. It occurs with any document, not just with yesterday’s HTML document. I’m investigating.
Updated by Gerrit Imsieke about 2 years ago
I circumvented it with this commit. The issue seems to arise when the predicate [ancestor-or-self::*]
is applied to a non-node, such as a string.
Updated by Martin Honnen about 2 years 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 about 2 years ago
- Sprint/Milestone set to SaxonJS 2.5
Updated by Gerrit Imsieke about 2 years ago
You should be able to reproduce the bug if you clone https://github.com/gimsieke/xpathle/, check out commit 00f1360b (before my fix), run create-sef.sh (with the Saxon EE jar location adjusted) and serve the directory from a Web server.
Updated by Norm Tovey-Walsh about 2 years ago
- Status changed from New to AwaitingInfo
Curiously, this bug doesn't occur if you compile with the XX compiler...
Updated by Norm Tovey-Walsh about 2 years 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 saxonjs2
and main
branches.
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.
Updated by Norm Tovey-Walsh about 2 years ago
- Status changed from Resolved to Closed
- % Done changed from 0 to 100
- Fixed in JS Release set to SaxonJS 2.5
Fixed in SaxonJS 2.5.
Please register to edit this issue
Also available in: Atom PDF Tracking page