NullPointerException after optimizing saxon:stream()
Execution of the following query fails with a NullPointerException:
let $x := saxon:stream(doc('temp/test.xml')/*/*) return $x
The reason is that in the course of optimizing the expression to remove the redundant variable, the saxon:stream() expression is copied, and in the course of copying it loses its reference to the "container" of the expression which holds location and context information; a subsequent reference to this container results in the NPE.
A patch to StreamingCopy.copy() is being committed.