On 19 Feb 2014, at 12:24, Rademacher, Gunther <Gunther.Rademacher@softwareag.com> wrote:

Finally managed to achieve the desired behavior. In contrast to yesterday’s
code snippet, the solution involves
-       invoking saxon:stream
-       isolating result processing into a separate path expression
      XQueryExecutable xqueryExecutable = xqueryCompiler.compile(
"for $x in saxon:stream(doc('" + input + "')/*/*) " +
"return string($x)");
      XQueryEvaluator query = xqueryExecutable.load();
      return query.iterator();
This now has timing independent of the document size:
      t(1): 0 msec
      t(64K): 718 msec
      t(492K): 5648 msec

Good to see this is working. 

saxon:stream() is a pseudo-function; its effect depends on the form of the expression in its argument, not just on the value of the expression, and the simplest rule is that the expression must be a call on doc() followed by something that looks like an XSLT pattern. So having /string() on the end will spoil it. You don't need a FLWOR: the following should work equally well:

saxon:stream(doc('" + input + "')/*/*)/string()

Michael Kay