Project

Profile

Help

Revision 889c6118

Added by Michael Kay over 1 year ago

Fix bug 4640

View differences:

latest10/hej/net/sf/saxon/expr/sort/DocumentSorter.java
139 139
                    ExpressionTool.copyLocationInfo(this, s1);
140 140
                    return new DocumentSorter(s1).optimize(visitor, contextInfo);
141 141
                }
142
                // docOrder(A/B) can be rewritten as docOrder(B) in the case where B returns nodes
142
                // docOrder(A/B) can be rewritten as head(A)!docOrder(B) in the case where B returns nodes
143 143
                // and is independent of the focus. We already know it returns nodes otherwise we wouldn't be here.
144
                // SEE BUG 4640
144 145
                if (!ExpressionTool.dependsOnFocus(rhs) &&
145 146
                        !rhs.hasSpecialProperty(StaticProperty.HAS_SIDE_EFFECTS) &&
146 147
                        rhs.hasSpecialProperty(StaticProperty.NO_NODES_NEWLY_CREATED)) {
147
                    setBaseExpression(slash.getRhsExpression());
148
                    return optimize(visitor, contextInfo);
148
                    Expression e1 = FirstItemExpression.makeFirstItemExpression(slash.getLhsExpression());
149
                    Expression e2 = new DocumentSorter(slash.getRhsExpression());
150
                    SlashExpression e3 = new SlashExpression(e1, e2);
151
                    ExpressionTool.copyLocationInfo(this, e3);
152
                    return e3.optimize(visitor, contextInfo);
149 153
                }
150 154
            }
151 155
            // Try once more after recomputing the static properties of the expression

Also available in: Unified diff