Bug #3470


SaxonJS 1.0.1 fails when calling the key() function; SaxonJS 1.0.0 works well

Added by Pieter Masereeuw almost 7 years ago. Updated almost 7 years ago.

Start date:
Due date:
% Done:


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


SaxonJS 1.0.1 stops with a message in the console when the key() function is called. My impression is that this happens during key initalization - it looks like if a null "flags" object is being dereferenced.

The message is:

Uncaught TypeError: Cannot read property 'indexOf' of null

I add a very small set of files that reproduces the problem. Use the html-file, click the button and watch the console.

Files (611 KB) Pieter Masereeuw, 2017-10-05 10:51
Actions #1

Updated by Debbie Lockett almost 7 years ago

  • Assignee set to Debbie Lockett
  • Priority changed from Low to Normal
  • Applies to JS Branch 1.0 added

Thanks for logging this Pieter, and producing the small example to reproduce the problem. There were some changes in the implementation of the key() function between releases 1.0.0 and 1.0.1 which have produced this bug. Should be straightforward to resolve!

Actions #2

Updated by Pieter Masereeuw almost 7 years ago

  • Company set to Pieter Masereeuw
  • Contact person set to Pieter Masereeuw

Yes, it took me some time to find the spot in my real application, but

after that, the error was surprisingly easy to reproduce.

Good luck!


On 10/05/2017 11:32 AM, Saxonica Developer Community wrote:

Actions #3

Updated by Debbie Lockett almost 7 years ago

  • Status changed from New to Resolved
  • Applies to JS Branch deleted (Trunk)
  • Fix Committed on JS Branch 1.0 added

The SEF supplied is generated using Note that the bug is not produced when using an SEF generated by

The Saxon-JS code changes between 1.0.0 and 1.0.1 were generally to handle changes in the SEF as produced by Saxon-EE 9.8 rather than 9.7. But unfortunately this bug slipped in causing the problem for 9.7 SEFs.

The problem is with the flags variable. The fix is to first check that there is actually a flags attribute on the declaration in the SEF, and if not, default to "" (rather than null, so that the subsequent flags.indexOf() call is OK). So:

var flags = keyDecl.getAttribute("flags");

is replaced by

var flags = keyDecl.hasAttribute("flags") ? keyDecl.getAttribute("flags") : "";

Fix committed on 1.0 branch. (The bug is not found in the trunk branch, due to other code improvements, e.g. the above check is already happening.)

Actions #4

Updated by Debbie Lockett almost 7 years ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in JS Release set to Saxon-JS 1.0.2

Bug fix applied in Saxon-JS 1.0.2 maintenance release.

Please register to edit this issue

Also available in: Atom PDF Tracking page