Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 280555 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/wst/xml/xpath2/processor/test/AbstractPsychoPathTest.java (-12 / +17 lines)
Lines 13-19 Link Here
13
 *     Jesper S Moller - bug 283404 - fixed locale  
13
 *     Jesper S Moller - bug 283404 - fixed locale  
14
 *     Jesper S Moller - bug 281159 - fix document URIs and also filter XML namespace
14
 *     Jesper S Moller - bug 281159 - fix document URIs and also filter XML namespace
15
 *     Jesper S Moller - bug 275610 - Avoid big time and memory overhead for externals
15
 *     Jesper S Moller - bug 275610 - Avoid big time and memory overhead for externals
16
 *     Jesper Steen Moeller - bug 282096 - make test harness handle all string encoding                                       translate function surrogate aware
16
 *     Jesper Steen Moeller - bug 282096 - make test harness handle all string encoding
17
 *     Jesper Steen Moller  - bug 280555 - Add pluggable collation support
17
 *******************************************************************************/
18
 *******************************************************************************/
18
package org.eclipse.wst.xml.xpath2.processor.test;
19
package org.eclipse.wst.xml.xpath2.processor.test;
19
20
Lines 173-180 Link Here
173
		return xsGrammars[0].toXSModel(xsGrammars);
174
		return xsGrammars[0].toXSModel(xsGrammars);
174
	}
175
	}
175
176
176
	protected DynamicContext setupDynamicContext(XSModel schema) {
177
	protected DefaultDynamicContext setupDynamicContext(XSModel schema) {
177
		DynamicContext dc = dynamicContext = new DefaultDynamicContext(schema, domDoc);
178
		DefaultDynamicContext dc = new DefaultDynamicContext(schema, domDoc);
179
		dynamicContext = dc;
180
		
178
		dc.add_namespace("xs", "http://www.w3.org/2001/XMLSchema");
181
		dc.add_namespace("xs", "http://www.w3.org/2001/XMLSchema");
179
		dc.add_namespace("xsd", "http://www.w3.org/2001/XMLSchema");
182
		dc.add_namespace("xsd", "http://www.w3.org/2001/XMLSchema");
180
		dc.add_namespace("fn", "http://www.w3.org/2005/xpath-functions");
183
		dc.add_namespace("fn", "http://www.w3.org/2005/xpath-functions");
Lines 352-367 Link Here
352
	protected DynamicContext setupVariables(DynamicContext dc) {
355
	protected DynamicContext setupVariables(DynamicContext dc) {
353
		dc.add_variable(new QName("x"));
356
		dc.add_variable(new QName("x"));
354
		dc.add_variable(new QName("var"));
357
		dc.add_variable(new QName("var"));
355
		AnyType docType = new DocType(domDoc);
358
		
356
		ElementType elementType = new ElementType(domDoc.getDocumentElement());
359
		if (domDoc != null) {
357
		dc.set_variable(new QName("input-context1"), docType);
360
			AnyType docType = new DocType(domDoc);
358
		dc.set_variable(new QName("input-context"), docType);
361
			ElementType elementType = new ElementType(domDoc.getDocumentElement());
359
		if (domDoc2 == null) {
362
			dc.set_variable(new QName("input-context1"), docType);
360
			dc.set_variable(new QName("input-context2"), docType);
363
			dc.set_variable(new QName("input-context"), docType);
361
		} else {
364
			if (domDoc2 == null) {
362
			dc.set_variable(new QName("input-context2"), (AnyType) new DocType(domDoc2));
365
				dc.set_variable(new QName("input-context2"), docType);
366
			} else {
367
				dc.set_variable(new QName("input-context2"), (AnyType) new DocType(domDoc2));
368
			}
363
		}
369
		}
364
365
		return dc;
370
		return dc;
366
	}
371
	}
367
372
(-)src/org/eclipse/wst/xml/xpath2/processor/test/TestBugs.java (+40 lines)
Lines 31-45 Link Here
31
 *                    bug 279376   improvements to xs:yearMonthDuration division operation
31
 *                    bug 279376   improvements to xs:yearMonthDuration division operation
32
 *                    bug 281046   implementation of xs:base64Binary data type                                
32
 *                    bug 281046   implementation of xs:base64Binary data type                                
33
 *  Jesper S Moller - bug 286061   correct handling of quoted string 
33
 *  Jesper S Moller - bug 286061   correct handling of quoted string 
34
 *  Jesper S Moller - bug 280555 - Add pluggable collation support
34
 *******************************************************************************/
35
 *******************************************************************************/
35
package org.eclipse.wst.xml.xpath2.processor.test;
36
package org.eclipse.wst.xml.xpath2.processor.test;
36
37
37
import java.net.URL;
38
import java.net.URL;
39
import java.util.Comparator;
38
40
39
import javax.xml.parsers.DocumentBuilder;
41
import javax.xml.parsers.DocumentBuilder;
40
import javax.xml.parsers.DocumentBuilderFactory;
42
import javax.xml.parsers.DocumentBuilderFactory;
41
43
42
import org.apache.xerces.xs.XSModel;
44
import org.apache.xerces.xs.XSModel;
45
import org.eclipse.wst.xml.xpath2.processor.CollationProvider;
46
import org.eclipse.wst.xml.xpath2.processor.DefaultDynamicContext;
43
import org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator;
47
import org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator;
44
import org.eclipse.wst.xml.xpath2.processor.DynamicContext;
48
import org.eclipse.wst.xml.xpath2.processor.DynamicContext;
45
import org.eclipse.wst.xml.xpath2.processor.Evaluator;
49
import org.eclipse.wst.xml.xpath2.processor.Evaluator;
Lines 53-58 Link Here
53
57
54
public class TestBugs extends AbstractPsychoPathTest {
58
public class TestBugs extends AbstractPsychoPathTest {
55
59
60
	private static final String URN_X_ECLIPSE_XPATH20_FUNKY_COLLATOR = "urn:x-eclipse:xpath20:funky-collator";
61
56
	public void testStringLengthWithElementArg() throws Exception {
62
	public void testStringLengthWithElementArg() throws Exception {
57
		// Bug 273719
63
		// Bug 273719
58
		URL fileURL = bundle.getEntry("/bugTestFiles/bug273719.xml");
64
		URL fileURL = bundle.getEntry("/bugTestFiles/bug273719.xml");
Lines 980-983 Link Here
980
		assertEquals("Don't try this at \"home\", she said", resultValue);
986
		assertEquals("Don't try this at \"home\", she said", resultValue);
981
	}
987
	}
982
988
989
	public void testBug280555_collations() throws Exception {
990
		// Setup context
991
		DefaultDynamicContext dc = setupDynamicContext(null);
992
		dc.set_collation_provider(createLengthCollatorProvider());
993
		Evaluator eval = new DefaultEvaluator(dc, domDoc);
994
995
		// Parse expression
996
		XPath path = compileXPath(dc, " 'abc' < 'de' ");
997
998
		// Evaluate once
999
		XSBoolean bval = (XSBoolean) eval.evaluate(path).first();
1000
		assertTrue("'abc' < 'def' for normal collations", bval.value());
1001
		
1002
		// Evaluate again with the funny collator
1003
		dc.set_default_collation(URN_X_ECLIPSE_XPATH20_FUNKY_COLLATOR);
1004
		XSBoolean bval2 = (XSBoolean) eval.evaluate(path).first();
1005
		assertFalse("'abc' < 'def' for normal collations", bval2.value());
1006
}
1007
1008
	private CollationProvider createLengthCollatorProvider() {
1009
		return new CollationProvider() {
1010
			public Comparator get_collation(String name) {
1011
				if (name.equals(URN_X_ECLIPSE_XPATH20_FUNKY_COLLATOR)) {
1012
					return new Comparator<String>() {
1013
						public int compare(String o1, String o2) {
1014
							return o1.length() - o2.length();
1015
						}
1016
					};
1017
				}
1018
				return null;
1019
			}
1020
		};
1021
	}
1022
983
}
1023
}
(-)src/org/eclipse/wst/xml/xpath2/processor/internal/types/XSBase64Binary.java (-1 / +2 lines)
Lines 13-18 Link Here
13
13
14
import org.apache.xerces.impl.dv.util.Base64;
14
import org.apache.xerces.impl.dv.util.Base64;
15
import org.apache.xerces.impl.dv.util.HexBin;
15
import org.apache.xerces.impl.dv.util.HexBin;
16
import org.eclipse.wst.xml.xpath2.processor.DynamicContext;
16
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
17
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
17
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
18
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
18
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
19
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
Lines 147-153 Link Here
147
	 *         
148
	 *         
148
	 * @throws DynamicError
149
	 * @throws DynamicError
149
	 */
150
	 */
150
	public boolean eq(AnyType arg) throws DynamicError {
151
	public boolean eq(AnyType arg, DynamicContext context) throws DynamicError {
151
      String valToCompare = arg.string_value();
152
      String valToCompare = arg.string_value();
152
      
153
      
153
      byte[] value1 = Base64.decode(_value);
154
      byte[] value1 = Base64.decode(_value);
(-)src/org/eclipse/wst/xml/xpath2/processor/internal/types/XSGYearMonth.java (-1 / +2 lines)
Lines 12-17 Link Here
12
12
13
package org.eclipse.wst.xml.xpath2.processor.internal.types;
13
package org.eclipse.wst.xml.xpath2.processor.internal.types;
14
14
15
import org.eclipse.wst.xml.xpath2.processor.DynamicContext;
15
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
16
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
16
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
17
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
17
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
18
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
Lines 282-288 Link Here
282
	 *         False otherwise
283
	 *         False otherwise
283
	 * @throws DynamicError
284
	 * @throws DynamicError
284
	 */
285
	 */
285
	public boolean eq(AnyType arg) throws DynamicError {
286
	public boolean eq(AnyType arg, DynamicContext context) throws DynamicError {
286
		XSGYearMonth val = (XSGYearMonth) NumericType.get_single_type(arg,
287
		XSGYearMonth val = (XSGYearMonth) NumericType.get_single_type(arg,
287
				XSGYearMonth.class);
288
				XSGYearMonth.class);
288
289
(-)src/org/eclipse/wst/xml/xpath2/processor/internal/types/XSDuration.java (-3 / +4 lines)
Lines 14-19 Link Here
14
14
15
import java.math.BigInteger;
15
import java.math.BigInteger;
16
16
17
import org.eclipse.wst.xml.xpath2.processor.DynamicContext;
17
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
18
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
18
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
19
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
19
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
20
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
Lines 229-235 Link Here
229
	 * @return True if they both represent the duration of time. False otherwise
230
	 * @return True if they both represent the duration of time. False otherwise
230
	 * @throws DynamicError
231
	 * @throws DynamicError
231
	 */
232
	 */
232
	public boolean eq(AnyType arg) throws DynamicError {
233
	public boolean eq(AnyType arg, DynamicContext context) throws DynamicError {
233
		XSDuration val = (XSDuration) NumericType.get_single_type(arg,
234
		XSDuration val = (XSDuration) NumericType.get_single_type(arg,
234
				XSDuration.class);
235
				XSDuration.class);
235
236
Lines 245-251 Link Here
245
	 *         stored. False otherwise
246
	 *         stored. False otherwise
246
	 * @throws DynamicError
247
	 * @throws DynamicError
247
	 */
248
	 */
248
	public boolean lt(AnyType arg) throws DynamicError {
249
	public boolean lt(AnyType arg, DynamicContext context) throws DynamicError {
249
		XSDuration val = (XSDuration) NumericType.get_single_type(arg,
250
		XSDuration val = (XSDuration) NumericType.get_single_type(arg,
250
				XSDayTimeDuration.class);
251
				XSDayTimeDuration.class);
251
252
Lines 261-267 Link Here
261
	 *         stored. False otherwise
262
	 *         stored. False otherwise
262
	 * @throws DynamicError
263
	 * @throws DynamicError
263
	 */
264
	 */
264
	public boolean gt(AnyType arg) throws DynamicError {
265
	public boolean gt(AnyType arg, DynamicContext context) throws DynamicError {
265
		XSDuration val = (XSDuration) NumericType.get_single_type(arg,
266
		XSDuration val = (XSDuration) NumericType.get_single_type(arg,
266
				XSDayTimeDuration.class);
267
				XSDayTimeDuration.class);
267
268
(-)src/org/eclipse/wst/xml/xpath2/processor/internal/types/XSGMonth.java (-1 / +2 lines)
Lines 12-17 Link Here
12
12
13
package org.eclipse.wst.xml.xpath2.processor.internal.types;
13
package org.eclipse.wst.xml.xpath2.processor.internal.types;
14
14
15
import org.eclipse.wst.xml.xpath2.processor.DynamicContext;
15
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
16
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
16
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
17
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
17
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
18
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
Lines 279-285 Link Here
279
	 *         otherwise
280
	 *         otherwise
280
	 * @throws DynamicError
281
	 * @throws DynamicError
281
	 */
282
	 */
282
	public boolean eq(AnyType arg) throws DynamicError {
283
	public boolean eq(AnyType arg, DynamicContext context) throws DynamicError {
283
		XSGMonth val = (XSGMonth) NumericType.get_single_type(arg,
284
		XSGMonth val = (XSGMonth) NumericType.get_single_type(arg,
284
				XSGMonth.class);
285
				XSGMonth.class);
285
286
(-)src/org/eclipse/wst/xml/xpath2/processor/internal/types/XSFloat.java (-4 / +5 lines)
Lines 22-27 Link Here
22
import java.text.DecimalFormat;
22
import java.text.DecimalFormat;
23
import java.util.Iterator;
23
import java.util.Iterator;
24
24
25
import org.eclipse.wst.xml.xpath2.processor.DynamicContext;
25
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
26
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
26
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
27
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
27
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
28
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
Lines 194-207 Link Here
194
195
195
	/**
196
	/**
196
	 * Equality comparison between this number and the supplied representation.
197
	 * Equality comparison between this number and the supplied representation.
197
	 * 
198
	 * @param aa
198
	 * @param aa
199
	 *            The datatype to compare with
199
	 *            The datatype to compare with
200
	 * 
200
	 * @return True if the two representations are of the same number. False
201
	 * @return True if the two representations are of the same number. False
201
	 *         otherwise
202
	 *         otherwise
202
	 * @throws DynamicError
203
	 * @throws DynamicError
203
	 */
204
	 */
204
	public boolean eq(AnyType aa) throws DynamicError {
205
	public boolean eq(AnyType aa, DynamicContext context) throws DynamicError {
205
		AnyType carg = convertArg(aa);
206
		AnyType carg = convertArg(aa);
206
		if (!(carg instanceof XSFloat))
207
		if (!(carg instanceof XSFloat))
207
			DynamicError.throw_type_error();
208
			DynamicError.throw_type_error();
Lines 220-226 Link Here
220
	 *         one stored. False otherwise
221
	 *         one stored. False otherwise
221
	 * @throws DynamicError
222
	 * @throws DynamicError
222
	 */
223
	 */
223
	public boolean gt(AnyType arg) throws DynamicError {
224
	public boolean gt(AnyType arg, DynamicContext context) throws DynamicError {
224
		AnyType carg = convertArg(arg);
225
		AnyType carg = convertArg(arg);
225
		XSFloat val = (XSFloat) get_single_type(carg, XSFloat.class);
226
		XSFloat val = (XSFloat) get_single_type(carg, XSFloat.class);
226
		return float_value() > val.float_value();
227
		return float_value() > val.float_value();
Lines 235-241 Link Here
235
	 *         one stored. False otherwise
236
	 *         one stored. False otherwise
236
	 * @throws DynamicError
237
	 * @throws DynamicError
237
	 */
238
	 */
238
	public boolean lt(AnyType arg) throws DynamicError {
239
	public boolean lt(AnyType arg, DynamicContext context) throws DynamicError {
239
		AnyType carg = convertArg(arg);
240
		AnyType carg = convertArg(arg);
240
		XSFloat val = (XSFloat) get_single_type(carg, XSFloat.class);
241
		XSFloat val = (XSFloat) get_single_type(carg, XSFloat.class);
241
		return float_value() < val.float_value();
242
		return float_value() < val.float_value();
(-)src/org/eclipse/wst/xml/xpath2/processor/internal/types/QName.java (-1 / +2 lines)
Lines 12-17 Link Here
12
12
13
package org.eclipse.wst.xml.xpath2.processor.internal.types;
13
package org.eclipse.wst.xml.xpath2.processor.internal.types;
14
14
15
import org.eclipse.wst.xml.xpath2.processor.DynamicContext;
15
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
16
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
16
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
17
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
17
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
18
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
Lines 321-327 Link Here
321
	 * @return True if the two represent the same node. False otherwise
322
	 * @return True if the two represent the same node. False otherwise
322
	 * @throws DynamicError
323
	 * @throws DynamicError
323
	 */
324
	 */
324
	public boolean eq(AnyType arg) throws DynamicError {
325
	public boolean eq(AnyType arg, DynamicContext context) throws DynamicError {
325
		QName val = (QName) NumericType.get_single_type(arg, QName.class);
326
		QName val = (QName) NumericType.get_single_type(arg, QName.class);
326
		return equals(val);
327
		return equals(val);
327
	}
328
	}
(-)src/org/eclipse/wst/xml/xpath2/processor/internal/types/XSDouble.java (-4 / +5 lines)
Lines 22-27 Link Here
22
import java.math.RoundingMode;
22
import java.math.RoundingMode;
23
import java.util.Iterator;
23
import java.util.Iterator;
24
24
25
import org.eclipse.wst.xml.xpath2.processor.DynamicContext;
25
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
26
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
26
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
27
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
27
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
28
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
Lines 241-255 Link Here
241
242
242
	/**
243
	/**
243
	 * Equality comparison between this number and the supplied representation.
244
	 * Equality comparison between this number and the supplied representation.
244
	 * 
245
	 * @param aa
245
	 * @param aa
246
	 *            Representation to be compared with (must currently be of type
246
	 *            Representation to be compared with (must currently be of type
247
	 *            XSDouble)
247
	 *            XSDouble)
248
	 * 
248
	 * @return True if the 2 representations represent the same number. False
249
	 * @return True if the 2 representations represent the same number. False
249
	 *         otherwise
250
	 *         otherwise
250
	 * @since 1.1
251
	 * @since 1.1
251
	 */
252
	 */
252
	public boolean eq(AnyType aa) throws DynamicError {
253
	public boolean eq(AnyType aa, DynamicContext context) throws DynamicError {
253
		ResultSequence rs = ResultSequenceFactory.create_new(aa);
254
		ResultSequence rs = ResultSequenceFactory.create_new(aa);
254
		ResultSequence crs = constructor(rs);
255
		ResultSequence crs = constructor(rs);
255
		
256
		
Lines 272-278 Link Here
272
	 * @return True if the supplied type represents a number smaller than this
273
	 * @return True if the supplied type represents a number smaller than this
273
	 *         one stored. False otherwise
274
	 *         one stored. False otherwise
274
	 */
275
	 */
275
	public boolean gt(AnyType arg) throws DynamicError {
276
	public boolean gt(AnyType arg, DynamicContext context) throws DynamicError {
276
		AnyType carg = convertArg(arg);
277
		AnyType carg = convertArg(arg);
277
		
278
		
278
		XSDouble val = (XSDouble) get_single_type(carg, XSDouble.class);
279
		XSDouble val = (XSDouble) get_single_type(carg, XSDouble.class);
Lines 297-303 Link Here
297
	 * @return True if the supplied type represents a number greater than this
298
	 * @return True if the supplied type represents a number greater than this
298
	 *         one stored. False otherwise
299
	 *         one stored. False otherwise
299
	 */
300
	 */
300
	public boolean lt(AnyType arg) throws DynamicError {
301
	public boolean lt(AnyType arg, DynamicContext context) throws DynamicError {
301
		AnyType carg = convertArg(arg);
302
		AnyType carg = convertArg(arg);
302
303
303
		XSDouble val = (XSDouble) get_single_type(carg, XSDouble.class);
304
		XSDouble val = (XSDouble) get_single_type(carg, XSDouble.class);
(-)src/org/eclipse/wst/xml/xpath2/processor/internal/types/XSDate.java (-3 / +4 lines)
Lines 15-20 Link Here
15
15
16
package org.eclipse.wst.xml.xpath2.processor.internal.types;
16
package org.eclipse.wst.xml.xpath2.processor.internal.types;
17
17
18
import org.eclipse.wst.xml.xpath2.processor.DynamicContext;
18
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
19
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
19
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
20
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
20
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
21
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
Lines 343-349 Link Here
343
	 * @return True if the two dates are represent the same exact point in time.
344
	 * @return True if the two dates are represent the same exact point in time.
344
	 *         False otherwise.
345
	 *         False otherwise.
345
	 */
346
	 */
346
	public boolean eq(AnyType arg) throws DynamicError {
347
	public boolean eq(AnyType arg, DynamicContext context) throws DynamicError {
347
		XSDate val = (XSDate) NumericType.get_single_type(arg, XSDate.class);
348
		XSDate val = (XSDate) NumericType.get_single_type(arg, XSDate.class);
348
349
349
		return calendar().equals(val.calendar());
350
		return calendar().equals(val.calendar());
Lines 358-364 Link Here
358
	 * @return True if in time, this date lies before the date supplied. False
359
	 * @return True if in time, this date lies before the date supplied. False
359
	 *         otherwise.
360
	 *         otherwise.
360
	 */
361
	 */
361
	public boolean lt(AnyType arg) throws DynamicError {
362
	public boolean lt(AnyType arg, DynamicContext context) throws DynamicError {
362
		XSDate val = (XSDate) NumericType.get_single_type(arg, XSDate.class);
363
		XSDate val = (XSDate) NumericType.get_single_type(arg, XSDate.class);
363
364
364
		return calendar().before(val.calendar());
365
		return calendar().before(val.calendar());
Lines 373-379 Link Here
373
	 * @return True if in time, this date lies after the date supplied. False
374
	 * @return True if in time, this date lies after the date supplied. False
374
	 *         otherwise.
375
	 *         otherwise.
375
	 */
376
	 */
376
	public boolean gt(AnyType arg) throws DynamicError {
377
	public boolean gt(AnyType arg, DynamicContext context) throws DynamicError {
377
		XSDate val = (XSDate) NumericType.get_single_type(arg, XSDate.class);
378
		XSDate val = (XSDate) NumericType.get_single_type(arg, XSDate.class);
378
379
379
		return calendar().after(val.calendar());
380
		return calendar().after(val.calendar());
(-)src/org/eclipse/wst/xml/xpath2/processor/internal/types/XSGDay.java (-1 / +2 lines)
Lines 13-18 Link Here
13
13
14
package org.eclipse.wst.xml.xpath2.processor.internal.types;
14
package org.eclipse.wst.xml.xpath2.processor.internal.types;
15
15
16
import org.eclipse.wst.xml.xpath2.processor.DynamicContext;
16
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
17
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
17
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
18
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
18
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
19
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
Lines 298-304 Link Here
298
	 *         otherwise
299
	 *         otherwise
299
	 * @throws DynamicError
300
	 * @throws DynamicError
300
	 */
301
	 */
301
	public boolean eq(AnyType arg) throws DynamicError {
302
	public boolean eq(AnyType arg, DynamicContext context) throws DynamicError {
302
		XSGDay val = (XSGDay) NumericType.get_single_type(arg, XSGDay.class);
303
		XSGDay val = (XSGDay) NumericType.get_single_type(arg, XSGDay.class);
303
304
304
		return calendar().equals(val.calendar());
305
		return calendar().equals(val.calendar());
(-)src/org/eclipse/wst/xml/xpath2/processor/internal/types/XSHexBinary.java (-1 / +2 lines)
Lines 14-19 Link Here
14
14
15
import org.apache.xerces.impl.dv.util.Base64;
15
import org.apache.xerces.impl.dv.util.Base64;
16
import org.apache.xerces.impl.dv.util.HexBin;
16
import org.apache.xerces.impl.dv.util.HexBin;
17
import org.eclipse.wst.xml.xpath2.processor.DynamicContext;
17
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
18
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
18
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
19
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
19
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
20
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
Lines 163-169 Link Here
163
	 *         
164
	 *         
164
	 * @throws DynamicError
165
	 * @throws DynamicError
165
	 */
166
	 */
166
	public boolean eq(AnyType arg) throws DynamicError {
167
	public boolean eq(AnyType arg, DynamicContext context) throws DynamicError {
167
      String valToCompare = arg.string_value();
168
      String valToCompare = arg.string_value();
168
      
169
      
169
      byte[] value1 = HexBin.decode(_value);
170
      byte[] value1 = HexBin.decode(_value);
(-)src/org/eclipse/wst/xml/xpath2/processor/internal/types/XSAnyURI.java (-3 / +4 lines)
Lines 19-24 Link Here
19
import java.util.ArrayList;
19
import java.util.ArrayList;
20
import java.util.Collection;
20
import java.util.Collection;
21
21
22
import org.eclipse.wst.xml.xpath2.processor.DynamicContext;
22
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
23
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
23
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
24
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
24
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
25
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
Lines 122-128 Link Here
122
	 *         otherwise
123
	 *         otherwise
123
	 * @throws DynamicError
124
	 * @throws DynamicError
124
	 */
125
	 */
125
	public boolean eq(AnyType arg) throws DynamicError {
126
	public boolean eq(AnyType arg, DynamicContext context) throws DynamicError {
126
		if (arg instanceof XSAnyURI || arg instanceof XSString) {
127
		if (arg instanceof XSAnyURI || arg instanceof XSString) {
127
			if (this.string_value().equals(arg.string_value())) {
128
			if (this.string_value().equals(arg.string_value())) {
128
				return true;
129
				return true;
Lines 139-145 Link Here
139
	 * must be of type xs:anyURI (or, by promotion of this, xs:string)
140
	 * must be of type xs:anyURI (or, by promotion of this, xs:string)
140
	 * @since 1.1
141
	 * @since 1.1
141
	 */
142
	 */
142
	public boolean gt(AnyType arg) throws DynamicError {
143
	public boolean gt(AnyType arg, DynamicContext context) throws DynamicError {
143
		if (!(arg instanceof XSAnyURI || arg instanceof XSString)) {
144
		if (!(arg instanceof XSAnyURI || arg instanceof XSString)) {
144
			throw DynamicError.throw_type_error();	
145
			throw DynamicError.throw_type_error();	
145
		}
146
		}
Lines 159-165 Link Here
159
	 * 
160
	 * 
160
	 * @since 1.1
161
	 * @since 1.1
161
	 */
162
	 */
162
	public boolean lt(AnyType arg) throws DynamicError {
163
	public boolean lt(AnyType arg, DynamicContext context) throws DynamicError {
163
		if (!(arg instanceof XSAnyURI || arg instanceof XSString)) {
164
		if (!(arg instanceof XSAnyURI || arg instanceof XSString)) {
164
			throw DynamicError.throw_type_error();
165
			throw DynamicError.throw_type_error();
165
		}
166
		}
(-)src/org/eclipse/wst/xml/xpath2/processor/internal/types/XSBoolean.java (-3 / +4 lines)
Lines 13-18 Link Here
13
13
14
package org.eclipse.wst.xml.xpath2.processor.internal.types;
14
package org.eclipse.wst.xml.xpath2.processor.internal.types;
15
15
16
import org.eclipse.wst.xml.xpath2.processor.DynamicContext;
16
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
17
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
17
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
18
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
18
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
19
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
Lines 144-150 Link Here
144
	 * @return New XSBoolean representation of true/false result of the equality
145
	 * @return New XSBoolean representation of true/false result of the equality
145
	 *         comparison
146
	 *         comparison
146
	 */
147
	 */
147
	public boolean eq(AnyType arg) throws DynamicError {
148
	public boolean eq(AnyType arg, DynamicContext context) throws DynamicError {
148
		XSBoolean barg = (XSBoolean) NumericType.get_single_type(arg,
149
		XSBoolean barg = (XSBoolean) NumericType.get_single_type(arg,
149
				XSBoolean.class);
150
				XSBoolean.class);
150
151
Lines 163-169 Link Here
163
	 * @return New XSBoolean representation of true/false result of the
164
	 * @return New XSBoolean representation of true/false result of the
164
	 *         comparison
165
	 *         comparison
165
	 */
166
	 */
166
	public boolean gt(AnyType arg) throws DynamicError {
167
	public boolean gt(AnyType arg, DynamicContext context) throws DynamicError {
167
		XSBoolean barg = (XSBoolean) NumericType.get_single_type(arg,
168
		XSBoolean barg = (XSBoolean) NumericType.get_single_type(arg,
168
				XSBoolean.class);
169
				XSBoolean.class);
169
170
Lines 186-192 Link Here
186
	 * @return New XSBoolean representation of true/false result of the
187
	 * @return New XSBoolean representation of true/false result of the
187
	 *         comparison
188
	 *         comparison
188
	 */
189
	 */
189
	public boolean lt(AnyType arg) throws DynamicError {
190
	public boolean lt(AnyType arg, DynamicContext context) throws DynamicError {
190
		XSBoolean barg = (XSBoolean) NumericType.get_single_type(arg,
191
		XSBoolean barg = (XSBoolean) NumericType.get_single_type(arg,
191
				XSBoolean.class);
192
				XSBoolean.class);
192
193
(-)src/org/eclipse/wst/xml/xpath2/processor/internal/types/XSInteger.java (-2 / +3 lines)
Lines 20-25 Link Here
20
import java.math.RoundingMode;
20
import java.math.RoundingMode;
21
import java.util.Iterator;
21
import java.util.Iterator;
22
22
23
import org.eclipse.wst.xml.xpath2.processor.DynamicContext;
23
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
24
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
24
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
25
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
25
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
26
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
Lines 292-298 Link Here
292
	 * (non-Javadoc)
293
	 * (non-Javadoc)
293
	 * @see org.eclipse.wst.xml.xpath2.processor.internal.types.XSDecimal#gt(org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType)
294
	 * @see org.eclipse.wst.xml.xpath2.processor.internal.types.XSDecimal#gt(org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType)
294
	 */
295
	 */
295
	public boolean gt(AnyType arg) throws DynamicError {
296
	public boolean gt(AnyType arg, DynamicContext context) throws DynamicError {
296
		AnyType carg = convertArg(arg);
297
		AnyType carg = convertArg(arg);
297
        XSInteger val = (XSInteger) get_single_type(carg, XSInteger.class);
298
        XSInteger val = (XSInteger) get_single_type(carg, XSInteger.class);
298
        
299
        
Lines 312-318 Link Here
312
	 * (non-Javadoc)
313
	 * (non-Javadoc)
313
	 * @see org.eclipse.wst.xml.xpath2.processor.internal.types.XSDecimal#lt(org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType)
314
	 * @see org.eclipse.wst.xml.xpath2.processor.internal.types.XSDecimal#lt(org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType)
314
	 */
315
	 */
315
	public boolean lt(AnyType arg) throws DynamicError {
316
	public boolean lt(AnyType arg, DynamicContext context) throws DynamicError {
316
		AnyType carg = convertArg(arg);
317
		AnyType carg = convertArg(arg);
317
        XSInteger val = (XSInteger) get_single_type(carg, XSInteger.class);
318
        XSInteger val = (XSInteger) get_single_type(carg, XSInteger.class);
318
        
319
        
(-)src/org/eclipse/wst/xml/xpath2/processor/internal/types/XSDecimal.java (-5 / +6 lines)
Lines 20-25 Link Here
20
import java.math.RoundingMode;
20
import java.math.RoundingMode;
21
import java.util.Iterator;
21
import java.util.Iterator;
22
22
23
import org.eclipse.wst.xml.xpath2.processor.DynamicContext;
23
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
24
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
24
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
25
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
25
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
26
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
Lines 189-203 Link Here
189
	// comparisons
190
	// comparisons
190
	/**
191
	/**
191
	 * Equality comparison between this number and the supplied representation.
192
	 * Equality comparison between this number and the supplied representation.
192
	 * 
193
	 * 
194
	 * @param at
193
	 * @param at
195
	 *            Representation to be compared with (must currently be of type
194
	 *            Representation to be compared with (must currently be of type
196
	 *            XSDecimal)
195
	 *            XSDecimal)
196
	 * 
197
	 * 
197
	 * @return True if the 2 representation represent the same number. False
198
	 * @return True if the 2 representation represent the same number. False
198
	 *         otherwise
199
	 *         otherwise
199
	 */
200
	 */
200
	public boolean eq(AnyType at) throws DynamicError {
201
	public boolean eq(AnyType at, DynamicContext context) throws DynamicError {
201
		
202
		
202
		ResultSequence rs = ResultSequenceFactory.create_new(at);
203
		ResultSequence rs = ResultSequenceFactory.create_new(at);
203
		
204
		
Lines 221-227 Link Here
221
	 * @return True if the supplied type represents a number smaller than this
222
	 * @return True if the supplied type represents a number smaller than this
222
	 *         one stored. False otherwise
223
	 *         one stored. False otherwise
223
	 */
224
	 */
224
	public boolean gt(AnyType arg) throws DynamicError {
225
	public boolean gt(AnyType arg, DynamicContext context) throws DynamicError {
225
		AnyType carg = convertArg(arg);
226
		AnyType carg = convertArg(arg);
226
		
227
		
227
		XSDecimal val = (XSDecimal) get_single_type(carg, XSDecimal.class);
228
		XSDecimal val = (XSDecimal) get_single_type(carg, XSDecimal.class);
Lines 244-250 Link Here
244
	 * @return True if the supplied type represents a number greater than this
245
	 * @return True if the supplied type represents a number greater than this
245
	 *         one stored. False otherwise
246
	 *         one stored. False otherwise
246
	 */
247
	 */
247
	public boolean lt(AnyType arg) throws DynamicError {
248
	public boolean lt(AnyType arg, DynamicContext context) throws DynamicError {
248
		AnyType carg = convertArg(arg);
249
		AnyType carg = convertArg(arg);
249
		XSDecimal val = (XSDecimal) get_single_type(carg, XSDecimal.class);
250
		XSDecimal val = (XSDecimal) get_single_type(carg, XSDecimal.class);
250
		return (_value.compareTo(val.getValue()) == -1);
251
		return (_value.compareTo(val.getValue()) == -1);
(-)src/org/eclipse/wst/xml/xpath2/processor/internal/types/XSString.java (-21 / +22 lines)
Lines 9-24 Link Here
9
 *     Andrea Bittau - initial API and implementation from the PsychoPath XPath 2.0
9
 *     Andrea Bittau - initial API and implementation from the PsychoPath XPath 2.0
10
 *     Mukul Gandhi - improved comparison of xs:string with other XDM types
10
 *     Mukul Gandhi - improved comparison of xs:string with other XDM types
11
 *  Jesper S Moller - bug 286061   correct handling of quoted string 
11
 *  Jesper S Moller - bug 286061   correct handling of quoted string 
12
 *  Jesper S Moller - bug 280555 - Add pluggable collation support
12
 *******************************************************************************/
13
 *******************************************************************************/
13
14
14
package org.eclipse.wst.xml.xpath2.processor.internal.types;
15
package org.eclipse.wst.xml.xpath2.processor.internal.types;
15
16
17
import java.math.BigInteger;
18
19
import org.eclipse.wst.xml.xpath2.processor.DynamicContext;
16
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
20
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
17
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
21
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
18
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
22
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
19
import org.eclipse.wst.xml.xpath2.processor.internal.function.*;
23
import org.eclipse.wst.xml.xpath2.processor.internal.function.CmpEq;
20
24
import org.eclipse.wst.xml.xpath2.processor.internal.function.CmpGt;
21
import java.util.*;
25
import org.eclipse.wst.xml.xpath2.processor.internal.function.CmpLt;
26
import org.eclipse.wst.xml.xpath2.processor.internal.function.FnCompare;
22
27
23
/**
28
/**
24
 * A representation of the String datatype
29
 * A representation of the String datatype
Lines 112-132 Link Here
112
	// comparisons
117
	// comparisons
113
118
114
	// 666 indicates death [compare returned empty seq]
119
	// 666 indicates death [compare returned empty seq]
115
	private int do_compare(AnyType arg) throws DynamicError {
120
	private int do_compare(AnyType arg, DynamicContext dc) throws DynamicError {
116
		Collection args = new ArrayList();
117
121
118
		ResultSequence rs = ResultSequenceFactory.create_new(this);
122
		ResultSequence rs = ResultSequenceFactory.create_new();
119
		args.add(rs);
123
		// XXX: This can't happen, I guess
120
		args.add(ResultSequenceFactory.create_new(new 
124
		if (arg == null) return 666;
121
				                       XSString(arg.string_value())));
122
		rs = FnCompare.compare(args);
123
124
		if (rs.empty())
125
			return 666;
126
125
127
		XSInteger i = (XSInteger) rs.first();
126
		XSString comparand = arg instanceof XSString ? (XSString)arg : new XSString(arg.string_value());
127
		
128
		BigInteger result = FnCompare.compare_string(dc.default_collation_name(), this, comparand, dc);
128
129
129
		return i.int_value().intValue();
130
		return result.intValue();
130
	}
131
	}
131
132
132
	/**
133
	/**
Lines 139-146 Link Here
139
	 *         otherwise
140
	 *         otherwise
140
	 * @throws DynamicError
141
	 * @throws DynamicError
141
	 */
142
	 */
142
	public boolean eq(AnyType arg) throws DynamicError {
143
	public boolean eq(AnyType arg, DynamicContext context) throws DynamicError {
143
		int cmp = do_compare(arg);
144
		int cmp = do_compare(arg, context);
144
145
145
		// XXX im not sure what to do here!!! because eq has to return
146
		// XXX im not sure what to do here!!! because eq has to return
146
		// something i fink....
147
		// something i fink....
Lines 160-167 Link Here
160
	 *         supplied. False otherwise
161
	 *         supplied. False otherwise
161
	 * @throws DynamicError
162
	 * @throws DynamicError
162
	 */
163
	 */
163
	public boolean gt(AnyType arg) throws DynamicError {
164
	public boolean gt(AnyType arg, DynamicContext context) throws DynamicError {
164
		int cmp = do_compare(arg);
165
		int cmp = do_compare(arg, context);
165
166
166
		assert cmp != 666;
167
		assert cmp != 666;
167
168
Lines 178-185 Link Here
178
	 *         False otherwise
179
	 *         False otherwise
179
	 * @throws DynamicError
180
	 * @throws DynamicError
180
	 */
181
	 */
181
	public boolean lt(AnyType arg) throws DynamicError {
182
	public boolean lt(AnyType arg, DynamicContext context) throws DynamicError {
182
		int cmp = do_compare(arg);
183
		int cmp = do_compare(arg, context);
183
184
184
		assert cmp != 666;
185
		assert cmp != 666;
185
186
(-)src/org/eclipse/wst/xml/xpath2/processor/internal/types/XSTime.java (-3 / +4 lines)
Lines 14-19 Link Here
14
14
15
package org.eclipse.wst.xml.xpath2.processor.internal.types;
15
package org.eclipse.wst.xml.xpath2.processor.internal.types;
16
16
17
import org.eclipse.wst.xml.xpath2.processor.DynamicContext;
17
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
18
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
18
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
19
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
19
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
20
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
Lines 335-341 Link Here
335
	 * @return True if both XSTime's represent the same time. False otherwise
336
	 * @return True if both XSTime's represent the same time. False otherwise
336
	 * @throws DynamicError
337
	 * @throws DynamicError
337
	 */
338
	 */
338
	public boolean eq(AnyType arg) throws DynamicError {
339
	public boolean eq(AnyType arg, DynamicContext context) throws DynamicError {
339
		XSTime val = (XSTime) NumericType.get_single_type(arg, XSTime.class);
340
		XSTime val = (XSTime) NumericType.get_single_type(arg, XSTime.class);
340
341
341
		return calendar().equals(val.calendar());
342
		return calendar().equals(val.calendar());
Lines 349-355 Link Here
349
	 * @return True if the supplied time represnts a point in time after that
350
	 * @return True if the supplied time represnts a point in time after that
350
	 *         represented by the time stored. False otherwise
351
	 *         represented by the time stored. False otherwise
351
	 */
352
	 */
352
	public boolean lt(AnyType arg) throws DynamicError {
353
	public boolean lt(AnyType arg, DynamicContext context) throws DynamicError {
353
		XSTime val = (XSTime) NumericType.get_single_type(arg, XSTime.class);
354
		XSTime val = (XSTime) NumericType.get_single_type(arg, XSTime.class);
354
355
355
		return calendar().before(val.calendar());
356
		return calendar().before(val.calendar());
Lines 364-370 Link Here
364
	 *         represented by the time stored. False otherwise
365
	 *         represented by the time stored. False otherwise
365
	 * @throws DynamicError
366
	 * @throws DynamicError
366
	 */
367
	 */
367
	public boolean gt(AnyType arg) throws DynamicError {
368
	public boolean gt(AnyType arg, DynamicContext context) throws DynamicError {
368
		XSTime val = (XSTime) NumericType.get_single_type(arg, XSTime.class);
369
		XSTime val = (XSTime) NumericType.get_single_type(arg, XSTime.class);
369
370
370
		return calendar().after(val.calendar());
371
		return calendar().after(val.calendar());
(-)src/org/eclipse/wst/xml/xpath2/processor/internal/types/XSGYear.java (-1 / +2 lines)
Lines 12-17 Link Here
12
12
13
package org.eclipse.wst.xml.xpath2.processor.internal.types;
13
package org.eclipse.wst.xml.xpath2.processor.internal.types;
14
14
15
import org.eclipse.wst.xml.xpath2.processor.DynamicContext;
15
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
16
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
16
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
17
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
17
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
18
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
Lines 264-270 Link Here
264
	 *         otherwise
265
	 *         otherwise
265
	 * @throws DynamicError
266
	 * @throws DynamicError
266
	 */
267
	 */
267
	public boolean eq(AnyType arg) throws DynamicError {
268
	public boolean eq(AnyType arg, DynamicContext context) throws DynamicError {
268
		XSGYear val = (XSGYear) NumericType.get_single_type(arg, XSGYear.class);
269
		XSGYear val = (XSGYear) NumericType.get_single_type(arg, XSGYear.class);
269
270
270
		return calendar().equals(val.calendar());
271
		return calendar().equals(val.calendar());
(-)src/org/eclipse/wst/xml/xpath2/processor/internal/types/XSYearMonthDuration.java (-4 / +5 lines)
Lines 17-22 Link Here
17
17
18
import java.math.BigDecimal;
18
import java.math.BigDecimal;
19
19
20
import org.eclipse.wst.xml.xpath2.processor.DynamicContext;
20
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
21
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
21
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
22
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
22
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
23
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
Lines 277-283 Link Here
277
	 * @return True if they both represent the duration of time. False otherwise
278
	 * @return True if they both represent the duration of time. False otherwise
278
	 * @throws DynamicError
279
	 * @throws DynamicError
279
	 */
280
	 */
280
	public boolean eq(AnyType arg) throws DynamicError {
281
	public boolean eq(AnyType arg, DynamicContext context) throws DynamicError {
281
		if (arg instanceof XSDayTimeDuration) {
282
		if (arg instanceof XSDayTimeDuration) {
282
			XSDayTimeDuration dayTimeDuration = (XSDayTimeDuration)arg;
283
			XSDayTimeDuration dayTimeDuration = (XSDayTimeDuration)arg;
283
			return (monthValue() == 0 && dayTimeDuration.value() == 0.0);
284
			return (monthValue() == 0 && dayTimeDuration.value() == 0.0);
Lines 287-293 Link Here
287
		}
288
		}
288
		XSDuration val = (XSDuration) NumericType
289
		XSDuration val = (XSDuration) NumericType
289
				.get_single_type(arg, XSDuration.class);
290
				.get_single_type(arg, XSDuration.class);
290
		return super.eq(val);
291
		return super.eq(val, context);
291
	}
292
	}
292
293
293
	/**
294
	/**
Lines 299-305 Link Here
299
	 *         stored. False otherwise
300
	 *         stored. False otherwise
300
	 * @throws DynamicError
301
	 * @throws DynamicError
301
	 */
302
	 */
302
	public boolean lt(AnyType arg) throws DynamicError {
303
	public boolean lt(AnyType arg, DynamicContext context) throws DynamicError {
303
		XSYearMonthDuration val = (XSYearMonthDuration) NumericType
304
		XSYearMonthDuration val = (XSYearMonthDuration) NumericType
304
				.get_single_type(arg, XSYearMonthDuration.class);
305
				.get_single_type(arg, XSYearMonthDuration.class);
305
306
Lines 315-321 Link Here
315
	 *         stored. False otherwise
316
	 *         stored. False otherwise
316
	 * @throws DynamicError
317
	 * @throws DynamicError
317
	 */
318
	 */
318
	public boolean gt(AnyType arg) throws DynamicError {
319
	public boolean gt(AnyType arg, DynamicContext context) throws DynamicError {
319
		XSYearMonthDuration val = (XSYearMonthDuration) NumericType
320
		XSYearMonthDuration val = (XSYearMonthDuration) NumericType
320
				.get_single_type(arg, XSYearMonthDuration.class);
321
				.get_single_type(arg, XSYearMonthDuration.class);
321
322
(-)src/org/eclipse/wst/xml/xpath2/processor/internal/types/XSDateTime.java (-3 / +4 lines)
Lines 15-20 Link Here
15
15
16
package org.eclipse.wst.xml.xpath2.processor.internal.types;
16
package org.eclipse.wst.xml.xpath2.processor.internal.types;
17
17
18
import org.eclipse.wst.xml.xpath2.processor.DynamicContext;
18
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
19
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
19
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
20
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
20
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
21
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
Lines 759-765 Link Here
759
	 * @return True if the two dates and times are represent the same exact
760
	 * @return True if the two dates and times are represent the same exact
760
	 *         point in time. False otherwise.
761
	 *         point in time. False otherwise.
761
	 */
762
	 */
762
	public boolean eq(AnyType arg) throws DynamicError {
763
	public boolean eq(AnyType arg, DynamicContext context) throws DynamicError {
763
		XSDateTime val = (XSDateTime) NumericType.get_single_type(arg,
764
		XSDateTime val = (XSDateTime) NumericType.get_single_type(arg,
764
				XSDateTime.class);
765
				XSDateTime.class);
765
766
Lines 776-782 Link Here
776
	 * @return True if in time, this date and time lies before the date and time
777
	 * @return True if in time, this date and time lies before the date and time
777
	 *         supplied. False otherwise.
778
	 *         supplied. False otherwise.
778
	 */
779
	 */
779
	public boolean lt(AnyType arg) throws DynamicError {
780
	public boolean lt(AnyType arg, DynamicContext context) throws DynamicError {
780
		XSDateTime val = (XSDateTime) NumericType.get_single_type(arg,
781
		XSDateTime val = (XSDateTime) NumericType.get_single_type(arg,
781
				XSDateTime.class);
782
				XSDateTime.class);
782
783
Lines 793-799 Link Here
793
	 * @return True if in time, this date and time lies after the date and time
794
	 * @return True if in time, this date and time lies after the date and time
794
	 *         supplied. False otherwise.
795
	 *         supplied. False otherwise.
795
	 */
796
	 */
796
	public boolean gt(AnyType arg) throws DynamicError {
797
	public boolean gt(AnyType arg, DynamicContext context) throws DynamicError {
797
		XSDateTime val = (XSDateTime) NumericType.get_single_type(arg,
798
		XSDateTime val = (XSDateTime) NumericType.get_single_type(arg,
798
				XSDateTime.class);
799
				XSDateTime.class);
799
800
(-)src/org/eclipse/wst/xml/xpath2/processor/internal/types/XSGMonthDay.java (-1 / +2 lines)
Lines 14-19 Link Here
14
14
15
package org.eclipse.wst.xml.xpath2.processor.internal.types;
15
package org.eclipse.wst.xml.xpath2.processor.internal.types;
16
16
17
import org.eclipse.wst.xml.xpath2.processor.DynamicContext;
17
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
18
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
18
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
19
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
19
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
20
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
Lines 313-319 Link Here
313
	 *         False otherwise
314
	 *         False otherwise
314
	 * @throws DynamicError
315
	 * @throws DynamicError
315
	 */
316
	 */
316
	public boolean eq(AnyType arg) throws DynamicError {
317
	public boolean eq(AnyType arg, DynamicContext context) throws DynamicError {
317
		XSGMonthDay val = (XSGMonthDay) NumericType.get_single_type(arg,
318
		XSGMonthDay val = (XSGMonthDay) NumericType.get_single_type(arg,
318
				XSGMonthDay.class);
319
				XSGMonthDay.class);
319
320
(-)src/org/eclipse/wst/xml/xpath2/processor/DynamicError.java (-1 / +20 lines)
Lines 12-17 Link Here
12
 *     Jesper Steen Moeller - bug 28149 - add more fn:error info
12
 *     Jesper Steen Moeller - bug 28149 - add more fn:error info
13
 *     Jesper Steen Moller  - bug 281159 - fix document loading and resolving URIs 
13
 *     Jesper Steen Moller  - bug 281159 - fix document loading and resolving URIs 
14
 *     Jesper Steen Moller  - Bug 286062 - Add FOAR0002  
14
 *     Jesper Steen Moller  - Bug 286062 - Add FOAR0002  
15
 *     Jesper Steen Moller  - bug 280555 - Add pluggable collation support
15
 *******************************************************************************/
16
 *******************************************************************************/
16
17
17
package org.eclipse.wst.xml.xpath2.processor;
18
package org.eclipse.wst.xml.xpath2.processor;
Lines 199-205 Link Here
199
200
200
		return new DynamicError("FOCH0001", error);
201
		return new DynamicError("FOCH0001", error);
201
	}
202
	}
202
	
203
204
	/**
205
	 * Returns the dynamic error for an unsupported normalization form
206
	 * 
207
	 * @param collationName
208
	 *            is the error
209
	 * @return the DynamicError.
210
	 * @since 1.1
211
	 * 
212
	 */
213
	public static DynamicError unsupported_collation(String collationName) {
214
		String error = "Unsupported collation URI. ";
215
216
		if (collationName != null)
217
			error += " " + collationName;
218
219
		return new DynamicError("FOCH0002", error);
220
	}
221
203
	/**
222
	/**
204
	 * Returns the dynamic error for an unsupported normalization form
223
	 * Returns the dynamic error for an unsupported normalization form
205
	 * 
224
	 * 
(-)src/org/eclipse/wst/xml/xpath2/processor/DynamicContext.java (-6 / +29 lines)
Lines 12-27 Link Here
12
 *     Jesper Moller- bug 281159 - fix document loading and resolving URIs 
12
 *     Jesper Moller- bug 281159 - fix document loading and resolving URIs 
13
 *     Jesper Moller- bug 286452 - always return the stable date/time from dynamic context
13
 *     Jesper Moller- bug 286452 - always return the stable date/time from dynamic context
14
 *     Jesper Moller- bug 275610 - Avoid big time and memory overhead for externals
14
 *     Jesper Moller- bug 275610 - Avoid big time and memory overhead for externals
15
 *     Jesper Moller- bug 280555 - Add pluggable collation support
15
 *******************************************************************************/
16
 *******************************************************************************/
16
17
17
package org.eclipse.wst.xml.xpath2.processor;
18
package org.eclipse.wst.xml.xpath2.processor;
18
19
19
import org.eclipse.wst.xml.xpath2.processor.internal.Focus;
20
import org.eclipse.wst.xml.xpath2.processor.internal.types.*;
21
22
import java.net.URI;
20
import java.net.URI;
23
import java.util.*;
21
import java.util.Collection;
24
import org.w3c.dom.*;
22
import java.util.Comparator;
23
import java.util.GregorianCalendar;
24
25
import org.eclipse.wst.xml.xpath2.processor.internal.Focus;
26
import org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType;
27
import org.eclipse.wst.xml.xpath2.processor.internal.types.QName;
28
import org.eclipse.wst.xml.xpath2.processor.internal.types.XSDuration;
25
29
26
/**
30
/**
27
 * Interface for dynamic context.
31
 * Interface for dynamic context.
Lines 29-34 Link Here
29
public interface DynamicContext extends StaticContext {
33
public interface DynamicContext extends StaticContext {
30
34
31
	/**
35
	/**
36
	 * The default collation which is guaranteed to always be implemented
37
	 */
38
	public static final String CODEPOINT_COLLATION = "http://www.w3.org/2005/xpath-functions/collation/codepoint";
39
40
	/**
32
	 * Get context item.
41
	 * Get context item.
33
	 * 
42
	 * 
34
	 * @return the context item.
43
	 * @return the context item.
Lines 138-143 Link Here
138
	 * @return Focus
147
	 * @return Focus
139
	 */
148
	 */
140
	public Focus focus();
149
	public Focus focus();
141
150
	
151
	/**
152
	 * Return a useful collator for the specified URI
153
	 * 
154
	 * @param uri
155
	 * @return A Jaa collator, or null, if no such Collator exists 
156
	 */
157
	public Comparator<Object> get_collation(String uri); 
158
	
159
	/**
160
	 * Returns the current default collator
161
	 * 
162
	 * @return The default name to use as the collator
163
	 */
164
	public String default_collation_name();
142
165
143
}
166
}
(-)src/org/eclipse/wst/xml/xpath2/processor/DefaultEvaluator.java (-13 / +14 lines)
Lines 11-16 Link Here
11
 *     Jesper Steen Moeller - bug 285145 - check arguments to op:to
11
 *     Jesper Steen Moeller - bug 285145 - check arguments to op:to
12
 *     Jesper Steen Moeller - bug 262765 - fixed node state iteration
12
 *     Jesper Steen Moeller - bug 262765 - fixed node state iteration
13
 *     Jesper Steen Moller  - bug 275610 - Avoid big time and memory overhead for externals
13
 *     Jesper Steen Moller  - bug 275610 - Avoid big time and memory overhead for externals
14
 *     Jesper Steen Moller  - bug 280555 - Add pluggable collation support
14
 *******************************************************************************/
15
 *******************************************************************************/
15
16
16
package org.eclipse.wst.xml.xpath2.processor;
17
package org.eclipse.wst.xml.xpath2.processor;
Lines 465-504 Link Here
465
466
466
			switch (cmpex.type()) {
467
			switch (cmpex.type()) {
467
			case CmpExpr.EQ:
468
			case CmpExpr.EQ:
468
				return FsEq.fs_eq_value(args);
469
				return FsEq.fs_eq_value(args, _dc);
469
470
470
			case CmpExpr.NE:
471
			case CmpExpr.NE:
471
				return FsNe.fs_ne_value(args);
472
				return FsNe.fs_ne_value(args, _dc);
472
473
473
			case CmpExpr.GT:
474
			case CmpExpr.GT:
474
				return FsGt.fs_gt_value(args);
475
				return FsGt.fs_gt_value(args, _dc);
475
476
476
			case CmpExpr.LT:
477
			case CmpExpr.LT:
477
				return FsLt.fs_lt_value(args);
478
				return FsLt.fs_lt_value(args, _dc);
478
479
479
			case CmpExpr.GE:
480
			case CmpExpr.GE:
480
				return FsGe.fs_ge_value(args);
481
				return FsGe.fs_ge_value(args, _dc);
481
482
482
			case CmpExpr.LE:
483
			case CmpExpr.LE:
483
				return FsLe.fs_le_value(args);
484
				return FsLe.fs_le_value(args, _dc);
484
485
485
			case CmpExpr.EQUALS:
486
			case CmpExpr.EQUALS:
486
				return FsEq.fs_eq_general(args);
487
				return FsEq.fs_eq_general(args, _dc);
487
488
488
			case CmpExpr.NOTEQUALS:
489
			case CmpExpr.NOTEQUALS:
489
				return FsNe.fs_ne_general(args);
490
				return FsNe.fs_ne_general(args, _dc);
490
491
491
			case CmpExpr.GREATER:
492
			case CmpExpr.GREATER:
492
				return FsGt.fs_gt_general(args);
493
				return FsGt.fs_gt_general(args, _dc);
493
494
494
			case CmpExpr.LESSTHAN:
495
			case CmpExpr.LESSTHAN:
495
				return FsLt.fs_lt_general(args);
496
				return FsLt.fs_lt_general(args, _dc);
496
497
497
			case CmpExpr.GREATEREQUAL:
498
			case CmpExpr.GREATEREQUAL:
498
				return FsGe.fs_ge_general(args);
499
				return FsGe.fs_ge_general(args, _dc);
499
500
500
			case CmpExpr.LESSEQUAL:
501
			case CmpExpr.LESSEQUAL:
501
				return FsLe.fs_le_general(args);
502
				return FsLe.fs_le_general(args, _dc);
502
503
503
			case CmpExpr.IS:
504
			case CmpExpr.IS:
504
			case CmpExpr.LESS_LESS:
505
			case CmpExpr.LESS_LESS:
Lines 1775-1781 Link Here
1775
			if (at instanceof NumericType) {
1776
			if (at instanceof NumericType) {
1776
				try {
1777
				try {
1777
					_g_xsint.set_int(BigInteger.valueOf(_dc.context_position()));
1778
					_g_xsint.set_int(BigInteger.valueOf(_dc.context_position()));
1778
					return FsEq.fs_eq_fast(at, _g_xsint);
1779
					return FsEq.fs_eq_fast(at, _g_xsint, _dc);
1779
				} catch (DynamicError err) {
1780
				} catch (DynamicError err) {
1780
					report_error(err);
1781
					report_error(err);
1781
1782
(-)src/org/eclipse/wst/xml/xpath2/processor/DefaultDynamicContext.java (+30 lines)
Lines 13-18 Link Here
13
 *     Jesper Moller- bug 281159 - fix document loading and resolving URIs 
13
 *     Jesper Moller- bug 281159 - fix document loading and resolving URIs 
14
 *     Jesper Moller- bug 286452 - always return the stable date/time from dynamic context
14
 *     Jesper Moller- bug 286452 - always return the stable date/time from dynamic context
15
 *     Jesper Moller- bug 275610 - Avoid big time and memory overhead for externals
15
 *     Jesper Moller- bug 275610 - Avoid big time and memory overhead for externals
16
 *     Jesper Moller- bug 280555 - Add pluggable collation support
16
 *******************************************************************************/
17
 *******************************************************************************/
17
18
18
package org.eclipse.wst.xml.xpath2.processor;
19
package org.eclipse.wst.xml.xpath2.processor;
Lines 23-28 Link Here
23
import org.eclipse.wst.xml.xpath2.processor.internal.function.*;
24
import org.eclipse.wst.xml.xpath2.processor.internal.function.*;
24
import org.eclipse.wst.xml.xpath2.processor.internal.types.*;
25
import org.eclipse.wst.xml.xpath2.processor.internal.types.*;
25
26
27
import java.text.Collator;
26
import java.util.*;
28
import java.util.*;
27
29
28
import org.w3c.dom.*;
30
import org.w3c.dom.*;
Lines 44-49 Link Here
44
	private XSDuration _tz;
46
	private XSDuration _tz;
45
	private Map _loaded_documents;
47
	private Map _loaded_documents;
46
	private GregorianCalendar _current_date_time;
48
	private GregorianCalendar _current_date_time;
49
	private String _default_collation_name = CODEPOINT_COLLATION;
50
	private CollationProvider _collation_provider;
47
51
48
	/**
52
	/**
49
	 * Constructor.
53
	 * Constructor.
Lines 242-245 Link Here
242
		super.set_variable(var, val);
246
		super.set_variable(var, val);
243
	}
247
	}
244
248
249
	public void set_default_collation(String _default_collation) {
250
		this._default_collation_name = _default_collation;
251
	}
252
253
	public String default_collation_name() {
254
		return _default_collation_name;
255
	}
256
257
	// We are explicitly NOT using generics here, in anticipation of JDK1.4 compatibility
258
	private static Comparator CODEPOINT_COMPARATOR = new Comparator() {
259
		
260
		public int compare(Object o1, Object o2) {
261
			return ((String)o1).compareTo((String)o2);
262
		}
263
	};
264
	
265
	public Comparator<Object> get_collation(String uri) {
266
		if (CODEPOINT_COLLATION.equals(uri)) return CODEPOINT_COMPARATOR;
267
		
268
		return _collation_provider != null ? _collation_provider.get_collation(uri) : null;
269
	}
270
	
271
	public void set_collation_provider(CollationProvider provider) {
272
		this._collation_provider = provider;
273
	}
274
	
245
}
275
}
(-)src/org/eclipse/wst/xml/xpath2/processor/internal/function/FsEq.java (-19 / +27 lines)
Lines 12-21 Link Here
12
 *     David Carver - bug 262765 - fixed comparison on sequence range values.
12
 *     David Carver - bug 262765 - fixed comparison on sequence range values.
13
 *     Jesper S Moller - bug 283214 - fix eq for untyped atomic values
13
 *     Jesper S Moller - bug 283214 - fix eq for untyped atomic values
14
 *     Jesper Steen Moeller - bug 285145 - implement full arity checking
14
 *     Jesper Steen Moeller - bug 285145 - implement full arity checking
15
 *     Jesper Steen Moeller - bug 280555 - Add pluggable collation support
15
 *******************************************************************************/
16
 *******************************************************************************/
16
17
17
package org.eclipse.wst.xml.xpath2.processor.internal.function;
18
package org.eclipse.wst.xml.xpath2.processor.internal.function;
18
19
20
import org.eclipse.wst.xml.xpath2.processor.DynamicContext;
19
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
21
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
20
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
22
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
21
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
23
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
Lines 49-55 Link Here
49
	public ResultSequence evaluate(Collection args) throws DynamicError {
51
	public ResultSequence evaluate(Collection args) throws DynamicError {
50
		assert args.size() >= min_arity() && args.size() <= max_arity();
52
		assert args.size() >= min_arity() && args.size() <= max_arity();
51
53
52
		return fs_eq_value(args);
54
		return fs_eq_value(args, dynamic_context());
53
	}
55
	}
54
56
55
	/**
57
	/**
Lines 100-108 Link Here
100
	 *             Dynamic error.
102
	 *             Dynamic error.
101
	 * @return Result of conversion.
103
	 * @return Result of conversion.
102
	 */
104
	 */
103
	public static ResultSequence fs_eq_value(Collection args)
105
	public static ResultSequence fs_eq_value(Collection args, DynamicContext dynamicContext)
104
			throws DynamicError {
106
			throws DynamicError {
105
		return do_cmp_value_op(args, CmpEq.class, "eq");
107
		return do_cmp_value_op(args, CmpEq.class, "eq", dynamicContext);
106
	}
108
	}
107
109
108
	/**
110
	/**
Lines 116-122 Link Here
116
	 *             Dynamic error.
118
	 *             Dynamic error.
117
	 * @return Result of Equality operation.
119
	 * @return Result of Equality operation.
118
	 */
120
	 */
119
	public static boolean fs_eq_fast(AnyType one, AnyType two)
121
	public static boolean fs_eq_fast(AnyType one, AnyType two, DynamicContext dynamicContext)
120
			throws DynamicError {
122
			throws DynamicError {
121
123
122
		one = FnData.atomize(one);
124
		one = FnData.atomize(one);
Lines 133-139 Link Here
133
135
134
		CmpEq cmpone = (CmpEq) one;
136
		CmpEq cmpone = (CmpEq) one;
135
137
136
		return cmpone.eq(two);
138
		return cmpone.eq(two, dynamicContext);
137
	}
139
	}
138
140
139
	/**
141
	/**
Lines 143-154 Link Here
143
	 *            input1 of any type.
145
	 *            input1 of any type.
144
	 * @param b
146
	 * @param b
145
	 *            input2 of any type.
147
	 *            input2 of any type.
148
	 * @param dc
149
	 *              Dynamic Context
146
	 * @throws DynamicError
150
	 * @throws DynamicError
147
	 *             Dynamic error.
151
	 *             Dynamic error.
148
	 * @return Result of Equality operation.
152
	 * @return Result of Equality operation.
149
	 */
153
	 */
150
	private static boolean do_general_pair(AnyType a, AnyType b,
154
	private static boolean do_general_pair(AnyType a, AnyType b,
151
			Method comparator) throws DynamicError {
155
			Method comparator, DynamicContext dc) throws DynamicError {
152
156
153
		// section 3.5.2
157
		// section 3.5.2
154
158
Lines 201-207 Link Here
201
		args.add(one);
205
		args.add(one);
202
		args.add(two);
206
		args.add(two);
203
207
204
		Object margs[] = { args };
208
		Object margs[] = { args, dc };
205
209
206
		ResultSequence result = null;
210
		ResultSequence result = null;
207
		try {
211
		try {
Lines 229-241 Link Here
229
	 * 
233
	 * 
230
	 * @param args
234
	 * @param args
231
	 *            input arguments.
235
	 *            input arguments.
236
	 * @param dc
237
	 *         Dynamic context 
232
	 * @throws DynamicError
238
	 * @throws DynamicError
233
	 *             Dynamic error.
239
	 *             Dynamic error.
234
	 * @return Result of general equality operation.
240
	 * @return Result of general equality operation.
235
	 */
241
	 */
236
	public static ResultSequence fs_eq_general(Collection args)
242
	public static ResultSequence fs_eq_general(Collection args, DynamicContext dc)
237
			throws DynamicError {
243
			throws DynamicError {
238
		return do_cmp_general_op(args, FsEq.class, "fs_eq_value");
244
		return do_cmp_general_op(args, FsEq.class, "fs_eq_value", dc);
239
	}
245
	}
240
246
241
	// voodoo 3
247
	// voodoo 3
Lines 253-270 Link Here
253
	 * @return Result of the operation.
259
	 * @return Result of the operation.
254
	 */
260
	 */
255
	public static ResultSequence do_cmp_general_op(Collection args, Class type,
261
	public static ResultSequence do_cmp_general_op(Collection args, Class type,
256
			String mname) throws DynamicError {
262
			String mname, DynamicContext dc) throws DynamicError {
257
263
258
		// do the voodoo
264
		// do the voodoo
259
		Method comparator = null;
265
		Method comparator = null;
260
266
261
		try {
267
		try {
262
			Class margsdef[] = { Collection.class };
268
			Class margsdef[] = { Collection.class, DynamicContext.class };
263
269
264
			comparator = type.getMethod(mname, margsdef);
270
			comparator = type.getMethod(mname, margsdef);
265
271
266
		} catch (NoSuchMethodException err) {
272
		} catch (NoSuchMethodException err) {
267
			assert false;
273
			throw new RuntimeException("Can¿'t find method : " + mname, err);
268
		}
274
		}
269
275
270
		// sanity check args and get them
276
		// sanity check args and get them
Lines 290-296 Link Here
290
			for (Iterator j = two.iterator(); j.hasNext();) {
296
			for (Iterator j = two.iterator(); j.hasNext();) {
291
				AnyType b = (AnyType) j.next();
297
				AnyType b = (AnyType) j.next();
292
298
293
				if (do_general_pair(a, b, comparator))
299
				if (do_general_pair(a, b, comparator, dc))
294
					return ResultSequenceFactory
300
					return ResultSequenceFactory
295
							.create_new(new XSBoolean(true));
301
							.create_new(new XSBoolean(true));
296
			}
302
			}
Lines 309-320 Link Here
309
	 *            type of the arguments.
315
	 *            type of the arguments.
310
	 * @param mname
316
	 * @param mname
311
	 *            Method name for template simulation.
317
	 *            Method name for template simulation.
318
	 * @param dynamicContext 
319
	 *             Dynamic error.
312
	 * @throws DynamicError
320
	 * @throws DynamicError
313
	 *             Dynamic error.
321
	 *             Dynamic error.
314
	 * @return Result of the operation.
322
	 * @return Result of the operation.
315
	 */
323
	 */
316
	public static ResultSequence do_cmp_value_op(Collection args, Class type,
324
	public static ResultSequence do_cmp_value_op(Collection args, Class type,
317
			String mname) throws DynamicError {
325
			String mname, DynamicContext dynamicContext) throws DynamicError {
318
326
319
		// sanity check args + convert em
327
		// sanity check args + convert em
320
		if (args.size() != 2)
328
		if (args.size() != 2)
Lines 339-367 Link Here
339
			DynamicError.throw_type_error();
347
			DynamicError.throw_type_error();
340
348
341
		try {
349
		try {
342
			Class margsdef[] = { AnyType.class };
350
			Class margsdef[] = { AnyType.class, DynamicContext.class };
343
			Method method = null;
351
			Method method = null;
344
352
345
			method = type.getMethod(mname, margsdef);
353
			method = type.getMethod(mname, margsdef);
346
354
347
			Object margs[] = { arg2.first() };
355
			Object margs[] = { arg2.first(), dynamicContext };
348
			Boolean cmpres = (Boolean) method.invoke(arg, margs);
356
			Boolean cmpres = (Boolean) method.invoke(arg, margs);
349
357
350
			return ResultSequenceFactory.create_new(new XSBoolean(cmpres
358
			return ResultSequenceFactory.create_new(new XSBoolean(cmpres
351
					.booleanValue()));
359
					.booleanValue()));
352
		} catch (NoSuchMethodException err) {
360
		} catch (NoSuchMethodException err) {
353
			assert false;
361
			assert false;
362
			throw new RuntimeException("cannot compare using method " + mname, err);
354
		} catch (IllegalAccessException err) {
363
		} catch (IllegalAccessException err) {
355
			assert false;
364
			assert false;
365
			throw new RuntimeException("cannot compare using method " + mname, err);
356
		} catch (InvocationTargetException err) {
366
		} catch (InvocationTargetException err) {
357
			Throwable ex = err.getTargetException();
367
			Throwable ex = err.getTargetException();
358
368
359
			if (ex instanceof DynamicError)
369
			if (ex instanceof DynamicError)
360
				throw (DynamicError) ex;
370
				throw (DynamicError) ex;
361
371
362
			ex.printStackTrace();
372
			throw new RuntimeException("cannot compare using method " + mname, ex);
363
			System.exit(1);
364
		}
373
		}
365
		return null; // unreach!
366
	}
374
	}
367
}
375
}
(-)src/org/eclipse/wst/xml/xpath2/processor/internal/function/FnIndexOf.java (-3 / +6 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     Andrea Bittau - initial API and implementation from the PsychoPath XPath 2.0 
9
 *     Andrea Bittau - initial API and implementation from the PsychoPath XPath 2.0 
10
 *     Jesper Moller - bug 280555 - Add pluggable collation support
10
 *******************************************************************************/
11
 *******************************************************************************/
11
12
12
package org.eclipse.wst.xml.xpath2.processor.internal.function;
13
package org.eclipse.wst.xml.xpath2.processor.internal.function;
Lines 15-20 Link Here
15
import java.util.Collection;
16
import java.util.Collection;
16
import java.util.Iterator;
17
import java.util.Iterator;
17
18
19
import org.eclipse.wst.xml.xpath2.processor.DynamicContext;
18
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
20
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
19
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
21
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
20
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
22
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
Lines 46-52 Link Here
46
	 */
48
	 */
47
	@Override
49
	@Override
48
	public ResultSequence evaluate(Collection args) throws DynamicError {
50
	public ResultSequence evaluate(Collection args) throws DynamicError {
49
		return index_of(args);
51
		return index_of(args, dynamic_context());
50
	}
52
	}
51
53
52
	/**
54
	/**
Lines 73-83 Link Here
73
	 * 
75
	 * 
74
	 * @param args
76
	 * @param args
75
	 *            Result from the expressions evaluation.
77
	 *            Result from the expressions evaluation.
78
	 * @param dynamicContext 
76
	 * @throws DynamicError
79
	 * @throws DynamicError
77
	 *             Dynamic error.
80
	 *             Dynamic error.
78
	 * @return Result of fn:index-of operation.
81
	 * @return Result of fn:index-of operation.
79
	 */
82
	 */
80
	public static ResultSequence index_of(Collection args) throws DynamicError {
83
	public static ResultSequence index_of(Collection args, DynamicContext dynamicContext) throws DynamicError {
81
84
82
		assert args.size() == 2;
85
		assert args.size() == 2;
83
86
Lines 101-107 Link Here
101
		for (Iterator i = arg1.iterator(); i.hasNext();) {
104
		for (Iterator i = arg1.iterator(); i.hasNext();) {
102
			CmpEq candidate = get_comparable((AnyType) i.next());
105
			CmpEq candidate = get_comparable((AnyType) i.next());
103
106
104
			if (candidate.eq(at))
107
			if (candidate.eq(at, dynamicContext))
105
				rs.add(new XSInteger(BigInteger.valueOf(index)));
108
				rs.add(new XSInteger(BigInteger.valueOf(index)));
106
109
107
			index++;
110
			index++;
(-)src/org/eclipse/wst/xml/xpath2/processor/internal/function/FnCompare.java (-20 / +36 lines)
Lines 8-17 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *     Andrea Bittau - initial API and implementation from the PsychoPath XPath 2.0 
9
 *     Andrea Bittau - initial API and implementation from the PsychoPath XPath 2.0 
10
 *     Jesper Steen Moeller - bug 285145 - implement full arity checking
10
 *     Jesper Steen Moeller - bug 285145 - implement full arity checking
11
 *     Jesper Steen Moeller - bug 280555 - Add pluggable collation support
11
 *******************************************************************************/
12
 *******************************************************************************/
12
13
13
package org.eclipse.wst.xml.xpath2.processor.internal.function;
14
package org.eclipse.wst.xml.xpath2.processor.internal.function;
14
15
16
import org.eclipse.wst.xml.xpath2.processor.DynamicContext;
15
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
17
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
16
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
18
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
17
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
19
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
Lines 58-65 Link Here
58
	 * Constructor of FnCompare.
60
	 * Constructor of FnCompare.
59
	 */
61
	 */
60
	public FnCompare() {
62
	public FnCompare() {
61
		// XXX: This should be 2-3 when compare learns how to deal with collations
63
		super(new QName("compare"), 2, 3);
62
		super(new QName("compare"), 2);
63
	}
64
	}
64
65
65
	/**
66
	/**
Lines 73-117 Link Here
73
	 */
74
	 */
74
	@Override
75
	@Override
75
	public ResultSequence evaluate(Collection args) throws DynamicError {
76
	public ResultSequence evaluate(Collection args) throws DynamicError {
76
		return compare(args);
77
		return compare(args, dynamic_context());
77
	}
78
	}
78
79
79
	/**
80
	/**
80
	 * Compare the arguments.
81
	 * Compare the arguments.
81
	 * 
82
	 * 
82
	 * @param args
83
	 * @param args
83
	 *            are compared.
84
	 *            are compared (optional 3rd argument is the collation)
85
	 * @param dynamicContext
86
	 * 	       Current dynamic context 
84
	 * @throws DynamicError
87
	 * @throws DynamicError
85
	 *             Dynamic error.
88
	 *             Dynamic error.
86
	 * @return The result of the comparison of the arguments.
89
	 * @return The result of the comparison of the arguments.
87
	 */
90
	 */
88
	public static ResultSequence compare(Collection args) throws DynamicError {
91
	public static ResultSequence compare(Collection args, DynamicContext dynamicContext) throws DynamicError {
89
		Collection cargs = Function.convert_arguments(args, expected_args());
92
		Collection cargs = Function.convert_arguments(args, expected_args());
90
93
91
		ResultSequence rs = ResultSequenceFactory.create_new();
92
93
		Iterator argiter = cargs.iterator();
94
		Iterator argiter = cargs.iterator();
94
		ResultSequence arg1 = (ResultSequence) argiter.next();
95
		ResultSequence arg1 = (ResultSequence) argiter.next();
95
		if (arg1.empty())
96
			return rs;
97
		ResultSequence arg2 = (ResultSequence) argiter.next();
96
		ResultSequence arg2 = (ResultSequence) argiter.next();
98
		if (arg2.empty())
99
			return rs;
100
97
101
		XSString xstr1 = (XSString) arg1.first();
98
		String collationUri = dynamicContext.default_collation_name();
102
		XSString xstr2 = (XSString) arg2.first();
99
		if (argiter.hasNext()) {
100
			ResultSequence collArg = (ResultSequence) argiter.next();
101
			collationUri = collArg.first().string_value();
102
		}
103
103
104
		// XXX collations!!!
104
		XSString xstr1 = arg1.empty() ? null : (XSString) arg1.first();
105
		int ret = xstr1.value().compareTo(xstr2.value());
105
		XSString xstr2 = arg2.empty() ? null : (XSString) arg2.first();
106
107
		BigInteger result = compare_string(collationUri, xstr1, xstr2, dynamicContext);
108
		if (result != null) {
109
			return ResultSequenceFactory.create_new(new XSInteger(result));
110
		} else {
111
			return ResultSequenceFactory.create_new();			
112
		}
113
	}
114
115
	public static BigInteger compare_string(String collationUri, XSString xstr1,
116
			XSString xstr2, DynamicContext dynamicContext) throws DynamicError {
117
		Comparator collator = dynamicContext.get_collation(collationUri);
118
		if (collator == null) throw DynamicError.unsupported_collation(collationUri);
119
120
		if (xstr1 == null || xstr2 == null) return null;
121
		
122
		int ret = collator.compare(xstr1.value(), xstr2.value());
106
123
107
		if (ret == 0)
124
		if (ret == 0)
108
			rs.add(new XSInteger(BigInteger.valueOf(0)));
125
			return BigInteger.ZERO;
109
		else if (ret < 0)
126
		else if (ret < 0)
110
			rs.add(new XSInteger(BigInteger.valueOf(-1)));
127
			return BigInteger.valueOf(-1);
111
		else
128
		else
112
			rs.add(new XSInteger(BigInteger.valueOf(1)));
129
			return BigInteger.ONE;
113
114
		return rs;
115
	}
130
	}
116
131
117
	/**
132
	/**
Lines 125-130 Link Here
125
			SeqType arg = new SeqType(new XSString(), SeqType.OCC_QMARK);
140
			SeqType arg = new SeqType(new XSString(), SeqType.OCC_QMARK);
126
			_expected_args.add(arg);
141
			_expected_args.add(arg);
127
			_expected_args.add(arg);
142
			_expected_args.add(arg);
143
			_expected_args.add(new SeqType(new XSString(), SeqType.OCC_NONE));
128
		}
144
		}
129
145
130
		return _expected_args;
146
		return _expected_args;
(-)src/org/eclipse/wst/xml/xpath2/processor/internal/function/CmpGt.java (-1 / +4 lines)
Lines 7-16 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     Andrea Bittau - initial API and implementation from the PsychoPath XPath 2.0 
9
 *     Andrea Bittau - initial API and implementation from the PsychoPath XPath 2.0 
10
 *     Jesper Moller - bug 280555 - Add pluggable collation support
10
 *******************************************************************************/
11
 *******************************************************************************/
11
12
12
package org.eclipse.wst.xml.xpath2.processor.internal.function;
13
package org.eclipse.wst.xml.xpath2.processor.internal.function;
13
14
15
import org.eclipse.wst.xml.xpath2.processor.DynamicContext;
14
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
16
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
15
import org.eclipse.wst.xml.xpath2.processor.internal.*;
17
import org.eclipse.wst.xml.xpath2.processor.internal.*;
16
import org.eclipse.wst.xml.xpath2.processor.internal.types.*;
18
import org.eclipse.wst.xml.xpath2.processor.internal.types.*;
Lines 24-32 Link Here
24
	 * 
26
	 * 
25
	 * @param arg
27
	 * @param arg
26
	 *            argument of any type.
28
	 *            argument of any type.
29
	 * @param context TODO
27
	 * @throws DynamicError
30
	 * @throws DynamicError
28
	 *             Dynamic error.
31
	 *             Dynamic error.
29
	 * @return Result of operation, true/false.
32
	 * @return Result of operation, true/false.
30
	 */
33
	 */
31
	public boolean gt(AnyType arg) throws DynamicError;
34
	public boolean gt(AnyType arg, DynamicContext context) throws DynamicError;
32
}
35
}
(-)src/org/eclipse/wst/xml/xpath2/processor/internal/function/CmpEq.java (-1 / +4 lines)
Lines 7-16 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     Andrea Bittau - initial API and implementation from the PsychoPath XPath 2.0 
9
 *     Andrea Bittau - initial API and implementation from the PsychoPath XPath 2.0 
10
 *     Jesper Moller - bug 280555 - Add pluggable collation support
10
 *******************************************************************************/
11
 *******************************************************************************/
11
12
12
package org.eclipse.wst.xml.xpath2.processor.internal.function;
13
package org.eclipse.wst.xml.xpath2.processor.internal.function;
13
14
15
import org.eclipse.wst.xml.xpath2.processor.DynamicContext;
14
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
16
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
15
import org.eclipse.wst.xml.xpath2.processor.internal.*;
17
import org.eclipse.wst.xml.xpath2.processor.internal.*;
16
import org.eclipse.wst.xml.xpath2.processor.internal.types.*;
18
import org.eclipse.wst.xml.xpath2.processor.internal.types.*;
Lines 24-32 Link Here
24
	 * 
26
	 * 
25
	 * @param arg
27
	 * @param arg
26
	 *            argument of any type.
28
	 *            argument of any type.
29
	 * @param context TODO
27
	 * @throws DynamicError
30
	 * @throws DynamicError
28
	 *             Dynamic error.
31
	 *             Dynamic error.
29
	 * @return Result of operation, true/false.
32
	 * @return Result of operation, true/false.
30
	 */
33
	 */
31
	public boolean eq(AnyType arg) throws DynamicError;
34
	public boolean eq(AnyType arg, DynamicContext context) throws DynamicError;
32
}
35
}
(-)src/org/eclipse/wst/xml/xpath2/processor/internal/function/FnMax.java (-3 / +7 lines)
Lines 7-16 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     Andrea Bittau - initial API and implementation from the PsychoPath XPath 2.0 
9
 *     Andrea Bittau - initial API and implementation from the PsychoPath XPath 2.0 
10
 *     Jesper Moller - bug 280555 - Add pluggable collation support
10
 *******************************************************************************/
11
 *******************************************************************************/
11
12
12
package org.eclipse.wst.xml.xpath2.processor.internal.function;
13
package org.eclipse.wst.xml.xpath2.processor.internal.function;
13
14
15
import org.eclipse.wst.xml.xpath2.processor.DynamicContext;
14
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
16
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
15
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
17
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
16
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
18
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
Lines 44-50 Link Here
44
	 */
46
	 */
45
	@Override
47
	@Override
46
	public ResultSequence evaluate(Collection args) throws DynamicError {
48
	public ResultSequence evaluate(Collection args) throws DynamicError {
47
		return max(args);
49
		return max(args, dynamic_context());
48
	}
50
	}
49
51
50
	/**
52
	/**
Lines 52-62 Link Here
52
	 * 
54
	 * 
53
	 * @param args
55
	 * @param args
54
	 *            Result from the expressions evaluation.
56
	 *            Result from the expressions evaluation.
57
	 * @param context 
58
	 *            Relevant dynamic context
55
	 * @throws DynamicError
59
	 * @throws DynamicError
56
	 *             Dynamic error.
60
	 *             Dynamic error.
57
	 * @return Result of fn:max operation.
61
	 * @return Result of fn:max operation.
58
	 */
62
	 */
59
	public static ResultSequence max(Collection args) throws DynamicError {
63
	public static ResultSequence max(Collection args, DynamicContext context) throws DynamicError {
60
64
61
		// XXX fix this
65
		// XXX fix this
62
		ResultSequence arg = get_arg(args, CmpGt.class);
66
		ResultSequence arg = get_arg(args, CmpGt.class);
Lines 76-82 Link Here
76
			if (max == null)
80
			if (max == null)
77
				max = item;
81
				max = item;
78
			else {
82
			else {
79
				boolean res = item.gt((AnyType) max);
83
				boolean res = item.gt((AnyType) max, context);
80
84
81
				if (res)
85
				if (res)
82
					max = item;
86
					max = item;
(-)src/org/eclipse/wst/xml/xpath2/processor/internal/function/FnDistinctValues.java (-5 / +7 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     Andrea Bittau - initial API and implementation from the PsychoPath XPath 2.0 
9
 *     Andrea Bittau - initial API and implementation from the PsychoPath XPath 2.0 
10
 *     Jesper Moller - bug 280555 - Add pluggable collation support
10
 *******************************************************************************/
11
 *******************************************************************************/
11
12
12
package org.eclipse.wst.xml.xpath2.processor.internal.function;
13
package org.eclipse.wst.xml.xpath2.processor.internal.function;
Lines 14-19 Link Here
14
import java.util.Collection;
15
import java.util.Collection;
15
import java.util.Iterator;
16
import java.util.Iterator;
16
17
18
import org.eclipse.wst.xml.xpath2.processor.DynamicContext;
17
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
19
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
18
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
20
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
19
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
21
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
Lines 48-54 Link Here
48
	 */
50
	 */
49
	@Override
51
	@Override
50
	public ResultSequence evaluate(Collection args) throws DynamicError {
52
	public ResultSequence evaluate(Collection args) throws DynamicError {
51
		return distinct_values(args);
53
		return distinct_values(args, dynamic_context());
52
	}
54
	}
53
55
54
	/**
56
	/**
Lines 62-68 Link Here
62
	 *             Dynamic error.
64
	 *             Dynamic error.
63
	 * @return Result of operation.
65
	 * @return Result of operation.
64
	 */
66
	 */
65
	private static boolean contains(ResultSequence rs, AnyAtomicType item)
67
	private static boolean contains(ResultSequence rs, AnyAtomicType item, DynamicContext context)
66
			throws DynamicError {
68
			throws DynamicError {
67
		if (!(item instanceof CmpEq))
69
		if (!(item instanceof CmpEq))
68
			return false;
70
			return false;
Lines 75-81 Link Here
75
77
76
			CmpEq cmp = (CmpEq) at;
78
			CmpEq cmp = (CmpEq) at;
77
79
78
			if (cmp.eq(item))
80
			if (cmp.eq(item, context))
79
				return true;
81
				return true;
80
82
81
		}
83
		}
Lines 91-97 Link Here
91
	 *             Dynamic error.
93
	 *             Dynamic error.
92
	 * @return Result of fn:distinct-values operation.
94
	 * @return Result of fn:distinct-values operation.
93
	 */
95
	 */
94
	public static ResultSequence distinct_values(Collection args)
96
	public static ResultSequence distinct_values(Collection args, DynamicContext context)
95
			throws DynamicError {
97
			throws DynamicError {
96
98
97
		assert args.size() == 1;
99
		assert args.size() == 1;
Lines 109-115 Link Here
109
			if (!(at instanceof AnyAtomicType))
111
			if (!(at instanceof AnyAtomicType))
110
				DynamicError.throw_type_error();
112
				DynamicError.throw_type_error();
111
113
112
			if (!contains(rs, (AnyAtomicType) at))
114
			if (!contains(rs, (AnyAtomicType) at, context))
113
				rs.add(at);
115
				rs.add(at);
114
		}
116
		}
115
117
(-)src/org/eclipse/wst/xml/xpath2/processor/internal/function/CmpLt.java (-1 / +4 lines)
Lines 7-16 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     Andrea Bittau - initial API and implementation from the PsychoPath XPath 2.0 
9
 *     Andrea Bittau - initial API and implementation from the PsychoPath XPath 2.0 
10
 *     Jesper Moller - bug 280555 - Add pluggable collation support
10
 *******************************************************************************/
11
 *******************************************************************************/
11
12
12
package org.eclipse.wst.xml.xpath2.processor.internal.function;
13
package org.eclipse.wst.xml.xpath2.processor.internal.function;
13
14
15
import org.eclipse.wst.xml.xpath2.processor.DynamicContext;
14
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
16
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
15
import org.eclipse.wst.xml.xpath2.processor.internal.*;
17
import org.eclipse.wst.xml.xpath2.processor.internal.*;
16
import org.eclipse.wst.xml.xpath2.processor.internal.types.*;
18
import org.eclipse.wst.xml.xpath2.processor.internal.types.*;
Lines 24-32 Link Here
24
	 * 
26
	 * 
25
	 * @param arg
27
	 * @param arg
26
	 *            argument of any type.
28
	 *            argument of any type.
29
	 * @param context TODO
27
	 * @throws DynamicError
30
	 * @throws DynamicError
28
	 *             Dynamic error.
31
	 *             Dynamic error.
29
	 * @return Result of operation, true/false.
32
	 * @return Result of operation, true/false.
30
	 */
33
	 */
31
	public boolean lt(AnyType arg) throws DynamicError;
34
	public boolean lt(AnyType arg, DynamicContext context) throws DynamicError;
32
}
35
}
(-)src/org/eclipse/wst/xml/xpath2/processor/internal/function/FsNe.java (-5 / +11 lines)
Lines 8-17 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *     Andrea Bittau - initial API and implementation from the PsychoPath XPath 2.0 
9
 *     Andrea Bittau - initial API and implementation from the PsychoPath XPath 2.0 
10
 *     Jesper Steen Moeller - bug 285145 - implement full arity checking
10
 *     Jesper Steen Moeller - bug 285145 - implement full arity checking
11
 *     Jesper Moller - bug 280555 - Add pluggable collation support
11
 *******************************************************************************/
12
 *******************************************************************************/
12
13
13
package org.eclipse.wst.xml.xpath2.processor.internal.function;
14
package org.eclipse.wst.xml.xpath2.processor.internal.function;
14
15
16
import org.eclipse.wst.xml.xpath2.processor.DynamicContext;
15
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
17
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
16
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
18
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
17
import org.eclipse.wst.xml.xpath2.processor.internal.*;
19
import org.eclipse.wst.xml.xpath2.processor.internal.*;
Lines 43-49 Link Here
43
	public ResultSequence evaluate(Collection args) throws DynamicError {
45
	public ResultSequence evaluate(Collection args) throws DynamicError {
44
		assert args.size() >= min_arity() && args.size() <= max_arity();
46
		assert args.size() >= min_arity() && args.size() <= max_arity();
45
47
46
		return fs_ne_value(args);
48
		return fs_ne_value(args, dynamic_context());
47
	}
49
	}
48
50
49
	/**
51
	/**
Lines 51-63 Link Here
51
	 * 
53
	 * 
52
	 * @param args
54
	 * @param args
53
	 *            input arguments.
55
	 *            input arguments.
56
	 * @param context 
57
	 *             The dynamic context
54
	 * @throws DynamicError
58
	 * @throws DynamicError
55
	 *             Dynamic error.
59
	 *             Dynamic error.
56
	 * @return Result of the operation.
60
	 * @return Result of the operation.
57
	 */
61
	 */
58
	public static ResultSequence fs_ne_value(Collection args)
62
	public static ResultSequence fs_ne_value(Collection args, DynamicContext context)
59
			throws DynamicError {
63
			throws DynamicError {
60
		return FnNot.fn_not(FsEq.fs_eq_value(args));
64
		return FnNot.fn_not(FsEq.fs_eq_value(args, context));
61
	}
65
	}
62
66
63
	/**
67
	/**
Lines 65-77 Link Here
65
	 * 
69
	 * 
66
	 * @param args
70
	 * @param args
67
	 *            input arguments.
71
	 *            input arguments.
72
	 * @param dc 
73
	 *             The dynamic context
68
	 * @throws DynamicError
74
	 * @throws DynamicError
69
	 *             Dynamic error.
75
	 *             Dynamic error.
70
	 * @return Result of the operation.
76
	 * @return Result of the operation.
71
	 */
77
	 */
72
	public static ResultSequence fs_ne_general(Collection args)
78
	public static ResultSequence fs_ne_general(Collection args, DynamicContext dc)
73
			throws DynamicError {
79
			throws DynamicError {
74
		return FsEq.do_cmp_general_op(args, FsNe.class, "fs_ne_value");
80
		return FsEq.do_cmp_general_op(args, FsNe.class, "fs_ne_value", dc);
75
	}
81
	}
76
82
77
}
83
}
(-)src/org/eclipse/wst/xml/xpath2/processor/internal/function/FsGe.java (-6 / +11 lines)
Lines 8-17 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *     Andrea Bittau - initial API and implementation from the PsychoPath XPath 2.0 
9
 *     Andrea Bittau - initial API and implementation from the PsychoPath XPath 2.0 
10
 *     Jesper Steen Moeller - bug 285145 - implement full arity checking
10
 *     Jesper Steen Moeller - bug 285145 - implement full arity checking
11
 *     Jesper Steen Mooller - bug 280555 - Add pluggable collation support
11
 *******************************************************************************/
12
 *******************************************************************************/
12
13
13
package org.eclipse.wst.xml.xpath2.processor.internal.function;
14
package org.eclipse.wst.xml.xpath2.processor.internal.function;
14
15
16
import org.eclipse.wst.xml.xpath2.processor.DynamicContext;
15
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
17
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
16
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
18
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
17
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
19
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
Lines 44-50 Link Here
44
	public ResultSequence evaluate(Collection args) throws DynamicError {
46
	public ResultSequence evaluate(Collection args) throws DynamicError {
45
		assert args.size() >= min_arity() && args.size() <= max_arity();
47
		assert args.size() >= min_arity() && args.size() <= max_arity();
46
48
47
		return fs_ge_value(args);
49
		return fs_ge_value(args, dynamic_context());
48
	}
50
	}
49
51
50
	/**
52
	/**
Lines 52-69 Link Here
52
	 * 
54
	 * 
53
	 * @param args
55
	 * @param args
54
	 *            input arguments.
56
	 *            input arguments.
57
	 * @param dc 
55
	 * @throws DynamicError
58
	 * @throws DynamicError
56
	 *             Dynamic error.
59
	 *             Dynamic error.
57
	 * @return Result of the operation.
60
	 * @return Result of the operation.
58
	 */
61
	 */
59
	public static ResultSequence fs_ge_value(Collection args)
62
	public static ResultSequence fs_ge_value(Collection args, DynamicContext dc)
60
			throws DynamicError {
63
			throws DynamicError {
61
		ResultSequence greater = FsGt.fs_gt_value(args);
64
		ResultSequence greater = FsGt.fs_gt_value(args, dc);
62
65
63
		if (((XSBoolean) greater.first()).value())
66
		if (((XSBoolean) greater.first()).value())
64
			return greater;
67
			return greater;
65
68
66
		ResultSequence equal = FsEq.fs_eq_value(args);
69
		ResultSequence equal = FsEq.fs_eq_value(args, dc);
67
70
68
		if (((XSBoolean) equal.first()).value())
71
		if (((XSBoolean) equal.first()).value())
69
			return equal;
72
			return equal;
Lines 76-87 Link Here
76
	 * 
79
	 * 
77
	 * @param args
80
	 * @param args
78
	 *            input arguments.
81
	 *            input arguments.
82
	 * @param dc 
83
	 *             The dynamic context
79
	 * @throws DynamicError
84
	 * @throws DynamicError
80
	 *             Dynamic error.
85
	 *             Dynamic error.
81
	 * @return Result of the operation.
86
	 * @return Result of the operation.
82
	 */
87
	 */
83
	public static ResultSequence fs_ge_general(Collection args)
88
	public static ResultSequence fs_ge_general(Collection args, DynamicContext dc)
84
			throws DynamicError {
89
			throws DynamicError {
85
		return FsEq.do_cmp_general_op(args, FsGe.class, "fs_ge_value");
90
		return FsEq.do_cmp_general_op(args, FsGe.class, "fs_ge_value", dc);
86
	}
91
	}
87
}
92
}
(-)src/org/eclipse/wst/xml/xpath2/processor/internal/function/FnMin.java (-3 / +7 lines)
Lines 7-16 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     Andrea Bittau - initial API and implementation from the PsychoPath XPath 2.0 
9
 *     Andrea Bittau - initial API and implementation from the PsychoPath XPath 2.0 
10
 *     Jesper Moller - bug 280555 - Add pluggable collation support
10
 *******************************************************************************/
11
 *******************************************************************************/
11
12
12
package org.eclipse.wst.xml.xpath2.processor.internal.function;
13
package org.eclipse.wst.xml.xpath2.processor.internal.function;
13
14
15
import org.eclipse.wst.xml.xpath2.processor.DynamicContext;
14
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
16
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
15
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
17
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
16
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
18
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
Lines 44-50 Link Here
44
	 */
46
	 */
45
	@Override
47
	@Override
46
	public ResultSequence evaluate(Collection args) throws DynamicError {
48
	public ResultSequence evaluate(Collection args) throws DynamicError {
47
		return min(args);
49
		return min(args, dynamic_context());
48
	}
50
	}
49
51
50
	/**
52
	/**
Lines 52-62 Link Here
52
	 * 
54
	 * 
53
	 * @param args
55
	 * @param args
54
	 *            Result from the expressions evaluation.
56
	 *            Result from the expressions evaluation.
57
	 * @param dynamic 
58
	 *            Dynamic context
55
	 * @throws DynamicError
59
	 * @throws DynamicError
56
	 *             Dynamic error.
60
	 *             Dynamic error.
57
	 * @return Result of fn:min operation.
61
	 * @return Result of fn:min operation.
58
	 */
62
	 */
59
	public static ResultSequence min(Collection args) throws DynamicError {
63
	public static ResultSequence min(Collection args, DynamicContext dynamic) throws DynamicError {
60
64
61
		// XXX fix this
65
		// XXX fix this
62
		ResultSequence arg = FnMax.get_arg(args, CmpLt.class);
66
		ResultSequence arg = FnMax.get_arg(args, CmpLt.class);
Lines 76-82 Link Here
76
			if (min == null)
80
			if (min == null)
77
				min = item;
81
				min = item;
78
			else {
82
			else {
79
				boolean res = item.lt((AnyType) min);
83
				boolean res = item.lt((AnyType) min, dynamic);
80
84
81
				if (res)
85
				if (res)
82
					min = item;
86
					min = item;
(-)src/org/eclipse/wst/xml/xpath2/processor/internal/function/FsLt.java (-5 / +11 lines)
Lines 8-17 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *     Andrea Bittau - initial API and implementation from the PsychoPath XPath 2.0 
9
 *     Andrea Bittau - initial API and implementation from the PsychoPath XPath 2.0 
10
 *     Jesper Steen Moeller - bug 285145 - implement full arity checking
10
 *     Jesper Steen Moeller - bug 285145 - implement full arity checking
11
 *     Jesper Moller - bug 280555 - Add pluggable collation support
11
 *******************************************************************************/
12
 *******************************************************************************/
12
13
13
package org.eclipse.wst.xml.xpath2.processor.internal.function;
14
package org.eclipse.wst.xml.xpath2.processor.internal.function;
14
15
16
import org.eclipse.wst.xml.xpath2.processor.DynamicContext;
15
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
17
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
16
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
18
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
17
import org.eclipse.wst.xml.xpath2.processor.internal.*;
19
import org.eclipse.wst.xml.xpath2.processor.internal.*;
Lines 43-49 Link Here
43
	public ResultSequence evaluate(Collection args) throws DynamicError {
45
	public ResultSequence evaluate(Collection args) throws DynamicError {
44
		assert args.size() >= min_arity() && args.size() <= max_arity();
46
		assert args.size() >= min_arity() && args.size() <= max_arity();
45
47
46
		return fs_lt_value(args);
48
		return fs_lt_value(args, dynamic_context());
47
	}
49
	}
48
50
49
	/**
51
	/**
Lines 51-63 Link Here
51
	 * 
53
	 * 
52
	 * @param args
54
	 * @param args
53
	 *            input arguments.
55
	 *            input arguments.
56
	 * @param context 
57
	 *             Dynamic context
54
	 * @throws DynamicError
58
	 * @throws DynamicError
55
	 *             Dynamic error.
59
	 *             Dynamic error.
56
	 * @return Result of the operation.
60
	 * @return Result of the operation.
57
	 */
61
	 */
58
	public static ResultSequence fs_lt_value(Collection args)
62
	public static ResultSequence fs_lt_value(Collection args, DynamicContext context)
59
			throws DynamicError {
63
			throws DynamicError {
60
		return FsEq.do_cmp_value_op(args, CmpLt.class, "lt");
64
		return FsEq.do_cmp_value_op(args, CmpLt.class, "lt", context);
61
	}
65
	}
62
66
63
	/**
67
	/**
Lines 65-76 Link Here
65
	 * 
69
	 * 
66
	 * @param args
70
	 * @param args
67
	 *            input arguments.
71
	 *            input arguments.
72
	 * @param dc 
73
	 *             The dynamic context
68
	 * @throws DynamicError
74
	 * @throws DynamicError
69
	 *             Dynamic error.
75
	 *             Dynamic error.
70
	 * @return Result of the operation.
76
	 * @return Result of the operation.
71
	 */
77
	 */
72
	public static ResultSequence fs_lt_general(Collection args)
78
	public static ResultSequence fs_lt_general(Collection args, DynamicContext dc)
73
			throws DynamicError {
79
			throws DynamicError {
74
		return FsEq.do_cmp_general_op(args, FsLt.class, "fs_lt_value");
80
		return FsEq.do_cmp_general_op(args, FsLt.class, "fs_lt_value", dc);
75
	}
81
	}
76
}
82
}
(-)src/org/eclipse/wst/xml/xpath2/processor/internal/function/FnDeepEqual.java (-11 / +18 lines)
Lines 7-16 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     Andrea Bittau - initial API and implementation from the PsychoPath XPath 2.0 
9
 *     Andrea Bittau - initial API and implementation from the PsychoPath XPath 2.0 
10
 *     Jesper Moller - bug 280555 - Add pluggable collation support
10
 *******************************************************************************/
11
 *******************************************************************************/
11
12
12
package org.eclipse.wst.xml.xpath2.processor.internal.function;
13
package org.eclipse.wst.xml.xpath2.processor.internal.function;
13
14
15
import org.eclipse.wst.xml.xpath2.processor.DynamicContext;
14
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
16
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
15
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
17
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
16
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
18
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
Lines 49-55 Link Here
49
	 */
51
	 */
50
	@Override
52
	@Override
51
	public ResultSequence evaluate(Collection args) throws DynamicError {
53
	public ResultSequence evaluate(Collection args) throws DynamicError {
52
		return deep_equal(args);
54
		return deep_equal(args, dynamic_context());
53
	}
55
	}
54
56
55
	/**
57
	/**
Lines 57-67 Link Here
57
	 * 
59
	 * 
58
	 * @param args
60
	 * @param args
59
	 *            Result from the expressions evaluation.
61
	 *            Result from the expressions evaluation.
62
	 * @param context
63
	 *            Dynamic context
60
	 * @throws DynamicError
64
	 * @throws DynamicError
61
	 *             Dynamic error.
65
	 *             Dynamic error.
62
	 * @return Result of fn:deep-equal operation.
66
	 * @return Result of fn:deep-equal operation.
63
	 */
67
	 */
64
	public static ResultSequence deep_equal(Collection args)
68
	public static ResultSequence deep_equal(Collection args, DynamicContext context)
65
			throws DynamicError {
69
			throws DynamicError {
66
70
67
		assert args.size() == 2;
71
		assert args.size() == 2;
Lines 71-77 Link Here
71
		ResultSequence arg1 = (ResultSequence) citer.next();
75
		ResultSequence arg1 = (ResultSequence) citer.next();
72
		ResultSequence arg2 = (ResultSequence) citer.next();
76
		ResultSequence arg2 = (ResultSequence) citer.next();
73
77
74
		boolean result = deep_equal(arg1, arg2);
78
		boolean result = deep_equal(arg1, arg2, context);
75
79
76
		return ResultSequenceFactory.create_new(new XSBoolean(result));
80
		return ResultSequenceFactory.create_new(new XSBoolean(result));
77
	}
81
	}
Lines 83-91 Link Here
83
	 *            input1 xpath expression/variable.
87
	 *            input1 xpath expression/variable.
84
	 * @param two
88
	 * @param two
85
	 *            input2 xpath expression/variable.
89
	 *            input2 xpath expression/variable.
90
	 * @param context
91
	 *            Current dynamic context 
86
	 * @return Result of fn:deep-equal operation.
92
	 * @return Result of fn:deep-equal operation.
87
	 */
93
	 */
88
	public static boolean deep_equal(ResultSequence one, ResultSequence two) {
94
	public static boolean deep_equal(ResultSequence one, ResultSequence two, DynamicContext context) {
89
		if (one.empty() && two.empty())
95
		if (one.empty() && two.empty())
90
			return true;
96
			return true;
91
97
Lines 99-105 Link Here
99
			AnyType a = (AnyType) onei.next();
105
			AnyType a = (AnyType) onei.next();
100
			AnyType b = (AnyType) twoi.next();
106
			AnyType b = (AnyType) twoi.next();
101
107
102
			if (!deep_equal(a, b))
108
			if (!deep_equal(a, b, context))
103
				return false;
109
				return false;
104
		}
110
		}
105
		return true;
111
		return true;
Lines 112-128 Link Here
112
	 *            input1 xpath expression/variable.
118
	 *            input1 xpath expression/variable.
113
	 * @param two
119
	 * @param two
114
	 *            input2 xpath expression/variable.
120
	 *            input2 xpath expression/variable.
121
	 * @param context 
115
	 * @return Result of fn:deep-equal operation.
122
	 * @return Result of fn:deep-equal operation.
116
	 */
123
	 */
117
	public static boolean deep_equal(AnyType one, AnyType two) {
124
	public static boolean deep_equal(AnyType one, AnyType two, DynamicContext context) {
118
		if ((one instanceof AnyAtomicType) && (two instanceof AnyAtomicType))
125
		if ((one instanceof AnyAtomicType) && (two instanceof AnyAtomicType))
119
			return deep_equal((AnyAtomicType) one, (AnyAtomicType) two);
126
			return deep_equal((AnyAtomicType) one, (AnyAtomicType) two, context);
120
127
121
		else if (((one instanceof AnyAtomicType) && (two instanceof NodeType))
128
		else if (((one instanceof AnyAtomicType) && (two instanceof NodeType))
122
				|| ((one instanceof NodeType) && (two instanceof AnyAtomicType)))
129
				|| ((one instanceof NodeType) && (two instanceof AnyAtomicType)))
123
			return false;
130
			return false;
124
		else if ((one instanceof NodeType) && (two instanceof NodeType))
131
		else if ((one instanceof NodeType) && (two instanceof NodeType))
125
			return deep_equal((NodeType) one, (NodeType) two);
132
			return deep_equal((NodeType) one, (NodeType) two, context);
126
		else {
133
		else {
127
			assert false;
134
			assert false;
128
			return false;
135
			return false;
Lines 138-144 Link Here
138
	 *            input2 xpath expression/variable.
145
	 *            input2 xpath expression/variable.
139
	 * @return Result of fn:deep-equal operation.
146
	 * @return Result of fn:deep-equal operation.
140
	 */
147
	 */
141
	public static boolean deep_equal(AnyAtomicType one, AnyAtomicType two) {
148
	public static boolean deep_equal(AnyAtomicType one, AnyAtomicType two, DynamicContext context) {
142
		if (!(one instanceof CmpEq))
149
		if (!(one instanceof CmpEq))
143
			return false;
150
			return false;
144
		if (!(two instanceof CmpEq))
151
		if (!(two instanceof CmpEq))
Lines 147-153 Link Here
147
		CmpEq a = (CmpEq) one;
154
		CmpEq a = (CmpEq) one;
148
155
149
		try {
156
		try {
150
			if (a.eq(two))
157
			if (a.eq(two, context))
151
				return true;
158
				return true;
152
			return false;
159
			return false;
153
		} catch (DynamicError err) {
160
		} catch (DynamicError err) {
Lines 164-170 Link Here
164
	 *            input2 xpath expression/variable.
171
	 *            input2 xpath expression/variable.
165
	 * @return Result of fn:deep-equal operation.
172
	 * @return Result of fn:deep-equal operation.
166
	 */
173
	 */
167
	public static boolean deep_equal(NodeType one, NodeType two) {
174
	public static boolean deep_equal(NodeType one, NodeType two, DynamicContext context) {
168
		Node a = one.node_value();
175
		Node a = one.node_value();
169
		Node b = two.node_value();
176
		Node b = two.node_value();
170
177
(-)src/org/eclipse/wst/xml/xpath2/processor/internal/function/FsLe.java (-6 / +12 lines)
Lines 8-17 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *     Andrea Bittau - initial API and implementation from the PsychoPath XPath 2.0 
9
 *     Andrea Bittau - initial API and implementation from the PsychoPath XPath 2.0 
10
 *     Jesper Steen Moeller - bug 285145 - implement full arity checking
10
 *     Jesper Steen Moeller - bug 285145 - implement full arity checking
11
 *     Jesper Moller - bug 280555 - Add pluggable collation support
11
 *******************************************************************************/
12
 *******************************************************************************/
12
13
13
package org.eclipse.wst.xml.xpath2.processor.internal.function;
14
package org.eclipse.wst.xml.xpath2.processor.internal.function;
14
15
16
import org.eclipse.wst.xml.xpath2.processor.DynamicContext;
15
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
17
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
16
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
18
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
17
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
19
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
Lines 44-50 Link Here
44
	public ResultSequence evaluate(Collection args) throws DynamicError {
46
	public ResultSequence evaluate(Collection args) throws DynamicError {
45
		assert args.size() >= min_arity() && args.size() <= max_arity();
47
		assert args.size() >= min_arity() && args.size() <= max_arity();
46
48
47
		return fs_le_value(args);
49
		return fs_le_value(args, dynamic_context());
48
	}
50
	}
49
51
50
	/**
52
	/**
Lines 52-69 Link Here
52
	 * 
54
	 * 
53
	 * @param args
55
	 * @param args
54
	 *            input arguments.
56
	 *            input arguments.
57
	 * @param 
58
     *         DynamicContext 
55
	 * @throws DynamicError
59
	 * @throws DynamicError
56
	 *             Dynamic error.
60
	 *             Dynamic error.
57
	 * @return Result of the operation.
61
	 * @return Result of the operation.
58
	 */
62
	 */
59
	public static ResultSequence fs_le_value(Collection args)
63
	public static ResultSequence fs_le_value(Collection args, DynamicContext dc)
60
			throws DynamicError {
64
			throws DynamicError {
61
		ResultSequence less = FsLt.fs_lt_value(args);
65
		ResultSequence less = FsLt.fs_lt_value(args, dc);
62
66
63
		if (((XSBoolean) less.first()).value())
67
		if (((XSBoolean) less.first()).value())
64
			return less;
68
			return less;
65
69
66
		ResultSequence equal = FsEq.fs_eq_value(args);
70
		ResultSequence equal = FsEq.fs_eq_value(args, dc);
67
71
68
		if (((XSBoolean) equal.first()).value())
72
		if (((XSBoolean) equal.first()).value())
69
			return equal;
73
			return equal;
Lines 76-87 Link Here
76
	 * 
80
	 * 
77
	 * @param args
81
	 * @param args
78
	 *            input arguments.
82
	 *            input arguments.
83
	 * @param dc 
84
	 *             The dynamic context
79
	 * @throws DynamicError
85
	 * @throws DynamicError
80
	 *             Dynamic error.
86
	 *             Dynamic error.
81
	 * @return Result of the operation.
87
	 * @return Result of the operation.
82
	 */
88
	 */
83
	public static ResultSequence fs_le_general(Collection args)
89
	public static ResultSequence fs_le_general(Collection args, DynamicContext dc)
84
			throws DynamicError {
90
			throws DynamicError {
85
		return FsEq.do_cmp_general_op(args, FsLe.class, "fs_le_value");
91
		return FsEq.do_cmp_general_op(args, FsLe.class, "fs_le_value", dc);
86
	}
92
	}
87
}
93
}
(-)src/org/eclipse/wst/xml/xpath2/processor/internal/function/FsGt.java (-5 / +11 lines)
Lines 8-17 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *     Andrea Bittau - initial API and implementation from the PsychoPath XPath 2.0 
9
 *     Andrea Bittau - initial API and implementation from the PsychoPath XPath 2.0 
10
 *     Jesper Steen Moeller - bug 285145 - implement full arity checking
10
 *     Jesper Steen Moeller - bug 285145 - implement full arity checking
11
 *     Jesper Steen Moeller - bug 280555 - Add pluggable collation support
11
 *******************************************************************************/
12
 *******************************************************************************/
12
13
13
package org.eclipse.wst.xml.xpath2.processor.internal.function;
14
package org.eclipse.wst.xml.xpath2.processor.internal.function;
14
15
16
import org.eclipse.wst.xml.xpath2.processor.DynamicContext;
15
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
17
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
16
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
18
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
17
import org.eclipse.wst.xml.xpath2.processor.internal.*;
19
import org.eclipse.wst.xml.xpath2.processor.internal.*;
Lines 43-49 Link Here
43
	public ResultSequence evaluate(Collection args) throws DynamicError {
45
	public ResultSequence evaluate(Collection args) throws DynamicError {
44
		assert args.size() >= min_arity() && args.size() <= max_arity();
46
		assert args.size() >= min_arity() && args.size() <= max_arity();
45
47
46
		return fs_gt_value(args);
48
		return fs_gt_value(args, dynamic_context());
47
	}
49
	}
48
50
49
	/**
51
	/**
Lines 51-63 Link Here
51
	 * 
53
	 * 
52
	 * @param args
54
	 * @param args
53
	 *            input arguments.
55
	 *            input arguments.
56
	 * @param dynamic
57
	 *             Dynamic contexet
54
	 * @throws DynamicError
58
	 * @throws DynamicError
55
	 *             Dynamic error.
59
	 *             Dynamic error.
56
	 * @return Result of the operation.
60
	 * @return Result of the operation.
57
	 */
61
	 */
58
	public static ResultSequence fs_gt_value(Collection args)
62
	public static ResultSequence fs_gt_value(Collection args, DynamicContext dynamic)
59
			throws DynamicError {
63
			throws DynamicError {
60
		return FsEq.do_cmp_value_op(args, CmpGt.class, "gt");
64
		return FsEq.do_cmp_value_op(args, CmpGt.class, "gt", dynamic);
61
	}
65
	}
62
66
63
	/**
67
	/**
Lines 65-77 Link Here
65
	 * 
69
	 * 
66
	 * @param args
70
	 * @param args
67
	 *            input arguments.
71
	 *            input arguments.
72
	 * @param dc 
73
	 *             The dynamic context
68
	 * @throws DynamicError
74
	 * @throws DynamicError
69
	 *             Dynamic error.
75
	 *             Dynamic error.
70
	 * @return Result of the operation.
76
	 * @return Result of the operation.
71
	 */
77
	 */
72
	public static ResultSequence fs_gt_general(Collection args)
78
	public static ResultSequence fs_gt_general(Collection args, DynamicContext dc)
73
			throws DynamicError {
79
			throws DynamicError {
74
		return FsEq.do_cmp_general_op(args, FsGt.class, "fs_gt_value");
80
		return FsEq.do_cmp_general_op(args, FsGt.class, "fs_gt_value", dc);
75
	}
81
	}
76
82
77
}
83
}
(-)src/org/eclipse/wst/xml/xpath2/processor/internal/function/FnDefaultCollation.java (-4 / +2 lines)
Lines 8-13 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *     David Carver (STAR) - initial API and implementation
9
 *     David Carver (STAR) - initial API and implementation
10
 *     Jesper Steen Moeller - bug 285145 - implement full arity checking
10
 *     Jesper Steen Moeller - bug 285145 - implement full arity checking
11
 *     Jesper Steen Moeller - bug 280555 - Add pluggable collation support
11
 *******************************************************************************/
12
 *******************************************************************************/
12
package org.eclipse.wst.xml.xpath2.processor.internal.function;
13
package org.eclipse.wst.xml.xpath2.processor.internal.function;
13
14
Lines 17-23 Link Here
17
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
18
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
18
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
19
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
19
import org.eclipse.wst.xml.xpath2.processor.internal.types.QName;
20
import org.eclipse.wst.xml.xpath2.processor.internal.types.QName;
20
import org.eclipse.wst.xml.xpath2.processor.internal.types.XSBoolean;
21
import org.eclipse.wst.xml.xpath2.processor.internal.types.XSString;
21
import org.eclipse.wst.xml.xpath2.processor.internal.types.XSString;
22
22
23
/**
23
/**
Lines 43-50 Link Here
43
 */
43
 */
44
public class FnDefaultCollation extends Function {
44
public class FnDefaultCollation extends Function {
45
45
46
	private static final String DEFAULT_COLLATION = "http://www.w3.org/2005/xpath-functions/collation/codepoint";
47
48
	public FnDefaultCollation() {
46
	public FnDefaultCollation() {
49
		super(new QName("default-collation"), 0);
47
		super(new QName("default-collation"), 0);
50
	}
48
	}
Lines 53-59 Link Here
53
	public ResultSequence evaluate(Collection args) throws DynamicError {
51
	public ResultSequence evaluate(Collection args) throws DynamicError {
54
		assert args.size() >= min_arity() && args.size() <= max_arity();
52
		assert args.size() >= min_arity() && args.size() <= max_arity();
55
		ResultSequence rs = ResultSequenceFactory.create_new();
53
		ResultSequence rs = ResultSequenceFactory.create_new();
56
		rs.add(new XSString(DEFAULT_COLLATION));
54
		rs.add(new XSString(dynamic_context().default_collation_name()));
57
		return rs;
55
		return rs;
58
	}
56
	}
59
57
(-)src/org/eclipse/wst/xml/xpath2/processor/CollationProvider.java (+28 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 Jesper Moller, and others
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Jesper Moller - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.wst.xml.xpath2.processor;
13
14
import java.util.Comparator;
15
16
/**
17
 * Service provider interface for looking up collations from within the dynamic context.
18
 */
19
public interface CollationProvider {
20
	/**
21
	 * Gets the named collator. W3C does not define collation names (yet?) so we are constrained to using an
22
	 * implementation-defined naming scheme.
23
	 * 
24
	 * @param name A URI designating the collation to use
25
	 * @return The collation to use, or null if no such collation exists by this provider
26
	 */
27
	Comparator get_collation(String name);
28
}

Return to bug 280555