Permalink
Browse files

Merge pull request #169 from wolfgangmm/develop

Fix incorrect processing of self axis step
  • Loading branch information...
dizzzz committed Mar 14, 2014
2 parents 3eb078d + b4d57ea commit 48d9f15696263970fa4fe4f38a6d47053418af0e
Showing with 38 additions and 5 deletions.
  1. +0 −2 src/org/exist/xquery/ElementConstructor.java
  2. +3 −3 src/org/exist/xquery/LetExpr.java
  3. +35 −0 test/src/xquery/selfAxis.xml
@@ -388,8 +388,6 @@ public String toString() {
* @see org.exist.xquery.AbstractExpression#setPrimaryAxis(int)
*/
public void setPrimaryAxis(int axis) {
- if(content != null)
- {content.setPrimaryAxis(axis);}
}
public int getPrimaryAxis() {
@@ -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);
@@ -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 48d9f15

Please sign in to comment.