From: Rademacher, Gunther <Gunther.R<ademacher@so...>  20111220 12:33:19

An exception as stated in the subject line was thrown while running some preexisting XQuery code on SaxonHE 9.4.0.1J. The shortest repro that I could come up with is this: declare function local:f($a, $b) as node()* { let $c := $a[1] return if (empty($a)) then $b else if ($c/self::y) then for $e at $i in $c/* where $i > 1 and $i < count($c/*) return $e else local:f($a[position() > 1], ($b, $c)) }; local:f(<x/>, ()) While reducing the original code, at one point I also saw a java.lang.ArrayIndexOutOfBoundsException: Local variable has not been allocated a stack frame slot It can be reproduced by declare function local:f($a, $b) as node()* { let $c := $a[1] return if (empty($a)) then $b else local:f ( $a[position() > 1], ( $b, for $e at $i in $c/* where $i > 1 and $i < count($c/*) return $e ) ) }; local:f(<u><v/><w/><y/></u>, ()) Best regards Gunther Software AG  Group Executive Board: KarlHeinz Streibich (Vorsitzender/Chairman), Arnd Zinnhardt, Mark Edwards, Dr. Wolfram Jost, Kamyar Niroumand, Darren Roos, Jonathan Smith, Ivo Totev Sitz/Registered office: Uhlandstra?e 12, 64297 Darmstadt, Germany  Registergericht/Commercial register: Darmstadt HRB 1562  Vorstand/Management Board: KarlHeinz Streibich (Vorsitzender/Chairman), Dr. Wolfram Jost, Arnd Zinnhardt http://www.softwareag.com/ 