Project

Profile

Help

Revision 812681d1

Added by Michael Kay 9 months ago

Retrofit patch for bug #4640 to the 9.9 branch

View differences:

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

Also available in: Unified diff