Skip to content
Browse files

[bugfix] A let expression should pass through the current context seq…

…uence when used inside a path expression.
  • Loading branch information...
1 parent 777d1df commit b4d57ea179c0cebbc09b36951a2c02780237ac17 @wolfgangmm wolfgangmm committed Mar 14, 2014
Showing with 38 additions and 3 deletions.
  1. +3 −3 src/org/exist/xquery/LetExpr.java
  2. +35 −0 test/src/xquery/selfAxis.xml
View
6 src/org/exist/xquery/LetExpr.java
@@ -184,9 +184,9 @@ public Sequence eval(Sequence contextSequence, Item contextItem,
resultSequence = new ValueSequence();
((ValueSequence)resultSequence).keepUnOrdered(unordered);
}
- ((BindingExpression)returnExpr).eval(null, null, resultSequence,null);
+ ((BindingExpression)returnExpr).eval(contextSequence, null, resultSequence,null);
} else {
- in = returnExpr.eval(null);
+ in = returnExpr.eval(contextSequence);
if (resultSequence == null)
{resultSequence = in;}
else
@@ -203,7 +203,7 @@ public Sequence eval(Sequence contextSequence, Item contextItem,
resultSequence = new ValueSequence();
((ValueSequence)resultSequence).keepUnOrdered(unordered);
}
- ((BindingExpression)returnExpr).eval(null, null, resultSequence, groupedSequence);
+ ((BindingExpression)returnExpr).eval(contextSequence, null, resultSequence, groupedSequence);
} else{
final Sequence toGroupSequence = context.resolveVariable(groupedSequence.getToGroupVarName()).getValue();
groupedSequence.addAll(toGroupSequence);
View
35 test/src/xquery/selfAxis.xml
@@ -144,4 +144,39 @@
</code>
<expected>6 3 2</expected>
</test>
+ <test output="xml">
+ <task>Self axis step used inside enclosed expression</task>
+ <code><![CDATA[
+ let $data :=
+ <root>
+ <elem>One</elem>
+ </root>
+ return
+ $data/elem/<data>{.,<a>1</a>}</data>
+ ]]></code>
+ <expected>
+ <data>
+ <elem>One</elem>
+ <a>1</a>
+ </data>
+ </expected>
+ </test>
+ <test output="xml">
+ <task>Context item should not be touched by nested let clause</task>
+ <code><![CDATA[
+ let $xml := <test><title>title</title></test>
+ return
+ $xml/title/<test>
+ {
+ let $title := ./text()
+ return
+ let $text := text()
+ return
+ $text
+ }
+ </test>]]></code>
+ <expected>
+ <test>title</test>
+ </expected>
+ </test>
</TestSet>

0 comments on commit b4d57ea

Please sign in to comment.
Something went wrong with that request. Please try again.