Bug #4523


"XError: looping???" from tokenize

Added by Debbie Lockett about 4 years ago. Updated over 3 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:
Contact person:
Additional contact persons:


Syd Bauman shared issue on saxon-help list:

"If I try to access a variable that has a long string I get an "XError: looping???" error. [...]

To see a nicely set up (if I do say so myself) demonstration and description of the bug (1), see

That tarball includes three files:

  • bug_demo.html: a host HTML file with a detailed description,
  • bug_demo.xml: a source XML document designed to make it easy to see how many words should be reported, and
  • bug_demo.xslt: an XSLT program that does very little above and beyond what is necessary to throw the error.

P.S. Just accessing the string isn't the problem, of course. E.g., string-length() seems to work."


bug_demo.html (4.9 KB) bug_demo.html Debbie Lockett, 2020-04-20 13:16
bug_demo.xml (8.77 KB) bug_demo.xml Debbie Lockett, 2020-04-20 13:16
bug_demo.xslt (1.95 KB) bug_demo.xslt Debbie Lockett, 2020-04-20 13:16
Actions #2

Updated by Debbie Lockett about 4 years ago

  • Status changed from New to In Progress

The error is thrown from the analyze function in Expr.js in Saxon-JS 1.2.0:

            if (loops++ > 1000) {
                throw XError("looping???", "SXJS0004");

This analyze function is called from analyze-string and tokenize in CoreFn.js, and formatNumberSeq in Numberer.js.

Note that the error still exists in Saxon-JS 2.0 code, but has been slightly updated. The relevant analyze function in now found in Push.js:

            if (loops++ > input.length * 10) {
                throw new XError("analyze-string looping???", "SXJS0004");

I see the error thrown running the demo with Saxon-JS 1.2.0, but not with Saxon-JS 2.0; I guess because of the loops++ > condition change.

Actions #3

Updated by Michael Kay about 4 years ago

That would be the problem then: Syd says he was using a very long string; if it contains more than 1,000 tokens then we're going to get this error, and the 2.0 change should fix it.

Actions #4

Updated by Debbie Lockett about 4 years ago

  • Status changed from In Progress to Resolved
  • Fix Committed on JS Branch 1.0 added

Copied 2.0 change for loops++ > condition to Saxon-JS 1 branch, and committed. (The error message is just left as is, because the error shouldn't ever actually happen...)

Actions #5

Updated by Norm Tovey-Walsh over 3 years ago

  • Status changed from Resolved to Closed

Please register to edit this issue

Also available in: Atom PDF Tracking page