Bug #5662


Uncaught TypeError: is not a function in today’s XPathle when using the “use stats“ button

Added by Gerrit Imsieke 9 months ago. Updated 8 months ago.

Start date:
Due date:
% Done:


Estimated time:
Applies to JS Branch:
2, Trunk
Fix Committed on JS Branch:
2, Trunk
Fixed in JS Release:
SEF Generated with:
Contact person:
Additional contact persons:


If you go to and push the “use stats” button and then hit Enter or push “Submit“, an error “Uncaught TypeError: 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().

Actions #1

Updated by Gerrit Imsieke 9 months 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.

Actions #2

Updated by Gerrit Imsieke 9 months 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.

Actions #3

Updated by Martin Honnen 9 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.

Actions #4

Updated by Norm Tovey-Walsh 9 months ago

  • Sprint/Milestone set to SaxonJS 2.5
Actions #5

Updated by Gerrit Imsieke 9 months ago

You should be able to reproduce the bug if you clone, check out commit 00f1360b (before my fix), run (with the Saxon EE jar location adjusted) and serve the directory from a Web server.

Actions #6

Updated by Norm Tovey-Walsh 8 months ago

  • Status changed from New to AwaitingInfo

Curiously, this bug doesn't occur if you compile with the XX compiler...

Actions #7

Updated by Norm Tovey-Walsh 8 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 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.

Actions #8

Updated by Norm Tovey-Walsh 8 months 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