Bug #2195

NullPointerException in com.saxonica.pull.TreeWalker

Added by Michael Kay over 5 years ago. Updated about 4 years ago.

Start date:
Due date:
% Done:


Legacy ID:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:


Gunther Rademacher reports on the saxon-help list:

I have a piece of code that worked with Saxon-EE 9.5, but throws a NPE with 9.6. It

uses PullToStax and TreeWalker to get Stax events from a DOM source.

A complete reproduction is shown below.

In the actual application, different types of sources are mapped to Stax events, for

peeking at some initial fragment of those sources. PullToStax came in handy to

accomplish this for DOM sources. I might of course implement that differently.

Concerning PullToStax and TreeWalker, I am not sure whether they are considered

part of the official API. I may also be misusing them in some way. Should I possibly

give up this approach?


#1 Updated by Michael Kay over 5 years ago

  • Status changed from New to Resolved

Thanks for reporting it. I've added your test case as a JUnit test and have produced a patch which will be committed on the 9.6 and 9.7 branches.

This code hasn't changed substantially for quite a while, but it was affected by a change to the SequenceIterator interface, and the change was made incorrectly. The general principle now is that SequenceIterator no longer maintains the values of position() and current(), and anyone who needs access to these values needs to wrap the SequenceIterator in a FocusTrackingIterator. It's then important always to call next() on the wrapping FocusTrackingIterator, but the TreeWalker fails to follow this rule and calls next() on the underlying SequenceIterator instead, leavng FocusTrackingIterator.current() set to null.

#2 Updated by O'Neil Delpratt over 5 years ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in version set to

Bug fix applied to the maintenance release Saxon

#3 Updated by O'Neil Delpratt about 4 years ago

  • Sprint/Milestone set to
  • Applies to branch 9.6 added
  • Fix Committed on Branch 9.6 added
  • Fixed in Maintenance Release added

Please register to edit this issue

Also available in: Atom PDF