Project

Profile

Help

Revision 99157cc0

Added by Michael Kay almost 13 years ago

Fix bug 2392479 - default-collation attribute in XSLT

View differences:

latest9.1/bj/net/sf/saxon/expr/GeneralComparison.java
194 194
            }
195 195

  
196 196
            ValueComparison vc = new ValueComparison(e0, singletonOperator, e1);
197
            vc.setAtomicComparer(comparer);
197 198
            ExpressionTool.copyLocationInfo(this, vc);
198 199
            return visitor.typeCheck(visitor.simplify(vc), contextItemType);
199 200
        }
200 201

  
201 202
        StaticContext env = visitor.getStaticContext();
202
        final String defaultCollationName = env.getDefaultCollationName();
203
        StringCollator collation = env.getCollation(defaultCollationName);
204
        if (collation == null) {
205
            collation = CodepointCollator.getInstance();
203

  
204
        if (comparer == null) {
205
            final String defaultCollationName = env.getDefaultCollationName();
206
            StringCollator collation = env.getCollation(defaultCollationName);
207
            if (collation == null) {
208
                collation = CodepointCollator.getInstance();
209
            }
210
            comparer = GenericAtomicComparer.makeAtomicComparer(
211
                    pt0, pt1, collation, visitor.getConfiguration().getConversionContext());
206 212
        }
207
        comparer = GenericAtomicComparer.makeAtomicComparer(
208
                pt0, pt1, collation, visitor.getConfiguration().getConversionContext());
209 213

  
210 214

  
211 215
        // evaluate the expression now if both arguments are constant
......
316 320
            }
317 321

  
318 322
            ValueComparison vc = new ValueComparison(e0, singletonOperator, e1);
323
            vc.setAtomicComparer(comparer);
319 324
            ExpressionTool.copyLocationInfo(this, vc);
320 325
            return visitor.optimize(visitor.typeCheck(visitor.simplify(vc), contextItemType), contextItemType);
321 326
        }
......
446 451
                            singletonOperator,
447 452
                            makeMinOrMax(e1, "max"));
448 453
                    vc.setResultWhenEmpty(BooleanValue.FALSE);
454
                    vc.setAtomicComparer(comparer);
449 455
                    break;
450 456
                case Token.GT:
451 457
                case Token.GE:
......
453 459
                            singletonOperator,
454 460
                            makeMinOrMax(e1, "min"));
455 461
                    vc.setResultWhenEmpty(BooleanValue.FALSE);
462
                    vc.setAtomicComparer(comparer);
456 463
                    break;
457 464
                default:
458 465
                    throw new UnsupportedOperationException("Unknown operator " + operator);
latest9.1/bj/net/sf/saxon/expr/ValueComparison.java
51 51
        }
52 52
    }
53 53

  
54
    /**
55
     * Set the AtomicComparer used to compare atomic values
56
     * @param comparer the AtomicComparer
57
     */
58

  
59
    public void setAtomicComparer(AtomicComparer comparer) {
60
        this.comparer = comparer;
61
    }
62

  
54 63
    /**
55 64
     * Get the AtomicComparer used to compare atomic values. This encapsulates any collation that is used.
56 65
     * Note that the comparer is always known at compile time.
......
207 216
            }
208 217
        }
209 218

  
210
        final String defaultCollationName = env.getDefaultCollationName();
211
        StringCollator comp = env.getCollation(defaultCollationName);
212
        if (comp == null) {
213
            comp = CodepointCollator.getInstance();
219
        if (comparer == null) {
220
            final String defaultCollationName = env.getDefaultCollationName();
221
            StringCollator comp = env.getCollation(defaultCollationName);
222
            if (comp == null) {
223
                comp = CodepointCollator.getInstance();
224
            }
225
            comparer = GenericAtomicComparer.makeAtomicComparer(
226
                    p0, p1, comp, env.getConfiguration().getConversionContext());
214 227
        }
215
        comparer = GenericAtomicComparer.makeAtomicComparer(
216
                p0, p1, comp, env.getConfiguration().getConversionContext());
217 228
        return this;
218 229
    }
219 230

  

Also available in: Unified diff