[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[Wtp-wst-dev] XPath2 - bugs + tests
|
Hello,
We have
compared CVS newest version with our local changes. Some of bugs
has similar
fixes, however there are still some which have not been fixed
yet. Proposed
fixes are in attached diffs. We tried to test our fixes using
existing files in
test case by adding methods to TestBugs.java.
1. FnAbs: http://www.w3.org/TR/xquery-operators/#func-abs
According
to http://www.w3.org/TR/xpath20/#id-function-callsif sequence is
expected (indicator
*, +, or ?) the atomization of arguments should be applied. Now
in case of node
passed to method type error occur. However there is some support
for
atomization - FnDistinctValues was fixed lately. Test case:
TestBugs:testFunctionAtomization()
We think
that in other numeric function similar errors can occur, suppose
other tests
should be added. Surprisingly there are no tests for that sort
of situation in conformance
suit (at least we haven’t found any).
2.
FnIndexOf: http://www.w3.org/TR/xquery-operators/#func-index-of
Function
should support any atomic values. It seems that there is no
support for QNames.
TestBugs:testFnIndexOf_onQName(),TestBugs:testFnIndexOf_onQName2()
Second test
function leads to third problem.
3. QName._expanded
which is boolean value saying if namespace was set (also null if
default). When
qname is created by function with empty first argument:
http://www.w3.org/TR/xquery-operators/#func-QName
then ._expanded
is ‘true’(we think it’s correct)
but to
compare it with qname from element will always return ‘false’
since Element.node_name() sets ._expanded to ‘false’ in case of
null
namespace (w3c.org representation of no-namespace situation is
null).
Removing if
statement in constructor (QName:45) seems to solve the problem
and do not
affected other tests. However we are not sure about correct
._expanded
parameter state. What is Your opinion?
4. FnPlus
used to have System.exit() line which caused us some trouble to
trace. It was
fixed but still there are plenty System.out statements for some
unusual errors.
Why just simply throw an exception?
We are
still investigating other differences trying to run our
application on new
library version. We will get back to You with any other fixes.
In the meantime
please let us know what do You think about those.
Regards,
Wojciech Diakowski
and
Łukasz Wycisk
|
Index: src/org/eclipse/wst/xml/xpath2/processor/internal/function/FnAbs.java
===================================================================
RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.xml.xpath2.processor/src/org/eclipse/wst/xml/xpath2/processor/internal/function/FnAbs.java,v
retrieving revision 1.8
diff -u -r1.8 FnAbs.java
--- src/org/eclipse/wst/xml/xpath2/processor/internal/function/FnAbs.java 19 Apr 2011 22:00:22 -0000 1.8
+++ src/org/eclipse/wst/xml/xpath2/processor/internal/function/FnAbs.java 12 Oct 2011 16:04:08 -0000
@@ -121,6 +121,7 @@
if (size == 0)
return null;
+ arg = FnData.atomize( arg );
AnyType at = (AnyType) arg.item(0);
if (!(at instanceof NumericType))
Index: src/org/eclipse/wst/xml/xpath2/processor/internal/function/FnIndexOf.java
===================================================================
RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.xml.xpath2.processor/src/org/eclipse/wst/xml/xpath2/processor/internal/function/FnIndexOf.java,v
retrieving revision 1.10
diff -u -r1.10 FnIndexOf.java
--- src/org/eclipse/wst/xml/xpath2/processor/internal/function/FnIndexOf.java 19 Apr 2011 22:00:23 -0000 1.10
+++ src/org/eclipse/wst/xml/xpath2/processor/internal/function/FnIndexOf.java 12 Oct 2011 16:04:09 -0000
@@ -156,6 +156,13 @@
rb.add(new XSInteger(BigInteger.valueOf(index)));
}
} else
+
+ if (at instanceof QName && cmptype instanceof QName ) {
+ QName qname = (QName)at;
+ if (qname.eq(cmptype, dc)) {
+ rb.add(new XSInteger(BigInteger.valueOf(index)));
+ }
+ } else
if (needsStringComparison(cmptype, at)) {
XSString xstr1 = new XSString(cmptype.getStringValue());
Index: src/org/eclipse/wst/xml/xpath2/processor/internal/types/QName.java
===================================================================
RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.xml.xpath2.processor/src/org/eclipse/wst/xml/xpath2/processor/internal/types/QName.java,v
retrieving revision 1.13
diff -u -r1.13 QName.java
--- src/org/eclipse/wst/xml/xpath2/processor/internal/types/QName.java 19 Apr 2011 22:00:23 -0000 1.13
+++ src/org/eclipse/wst/xml/xpath2/processor/internal/types/QName.java 12 Oct 2011 16:04:09 -0000
@@ -46,9 +46,9 @@
*/
public QName(String prefix, String local_part, String ns) {
this(prefix, local_part);
- if (ns != null) {
+ // if (ns != null) {
set_namespace(ns);
- }
+ // }
}
/**
Index: src/org/eclipse/wst/xml/xpath2/processor/test/TestBugs.java
===================================================================
RCS file: /cvsroot/webtools/sourceediting/tests/org.eclipse.wst.xml.xpath2.processor.tests/src/org/eclipse/wst/xml/xpath2/processor/test/TestBugs.java,v
retrieving revision 1.73
diff -u -r1.73 TestBugs.java
--- src/org/eclipse/wst/xml/xpath2/processor/test/TestBugs.java 8 Oct 2011 11:50:45 -0000 1.73
+++ src/org/eclipse/wst/xml/xpath2/processor/test/TestBugs.java 12 Oct 2011 16:04:43 -0000
@@ -1829,6 +1829,30 @@
assertEquals("true", actual);
}
+ public void testFunctionAtomization() throws Exception {
+ // Bug 318313
+ URL fileURL = bundle.getEntry("/bugTestFiles/bug318313.xml");
+ URL schemaURL = bundle.getEntry("/bugTestFiles/bug318313.xsd");
+
+ loadDOMDocument(fileURL, schemaURL);
+
+ // Get XSModel object for the Schema
+ XSModel schema = getGrammar(schemaURL);
+
+ setupDynamicContext(schema);
+
+ String xpath = "abs(X)";
+ compileXPath(xpath);
+ ResultSequence rs = evaluate(domDoc);
+
+
+ XSInteger result = (XSInteger) rs.first();
+
+ String actual = result.getStringValue();
+
+ assertEquals("100", actual);
+ }
+
public void testTypedValueEnhancement_Bug323900_1() throws Exception {
// Bug 323900
URL fileURL = bundle.getEntry("/bugTestFiles/bug323900_1.xml");
@@ -2351,6 +2375,48 @@
assertEquals("true", actual);
}
+ public void testFnIndexOf_onQName() throws Exception {
+ // bug 338999
+ URL fileURL = bundle.getEntry("/bugTestFiles/bug338999.xml");
+ URL schemaURL = bundle.getEntry("/bugTestFiles/bug338999.xsd");
+
+ loadDOMDocument(fileURL, schemaURL);
+
+ // Get XSModel object for the Schema
+ XSModel schema = getGrammar(schemaURL);
+
+ setupDynamicContext(schema);
+
+ String xpath = "fn:index-of( for $e in X/* return fn:node-name($e), fn:node-name(X/b) )";
+ compileXPath(xpath);
+ ResultSequence rs = evaluate(domDoc);
+
+ assertTrue( rs.size()>0 );
+ String actual = ((XSInteger) rs.first()).getStringValue();
+ assertEquals("2", actual);
+ }
+
+ public void testFnIndexOf_onQName2() throws Exception {
+ // bug 338999
+ URL fileURL = bundle.getEntry("/bugTestFiles/bug338999.xml");
+ URL schemaURL = bundle.getEntry("/bugTestFiles/bug338999.xsd");
+
+ loadDOMDocument(fileURL, schemaURL);
+
+ // Get XSModel object for the Schema
+ XSModel schema = getGrammar(schemaURL);
+
+ setupDynamicContext(schema);
+
+ String xpath = "fn:index-of( for $e in X/* return fn:node-name($e), fn:QName('','b') )";
+ compileXPath(xpath);
+ ResultSequence rs = evaluate(domDoc);
+
+ assertTrue( rs.size()>0 );
+ String actual = ((XSInteger) rs.first()).getStringValue();
+ assertEquals("2", actual);
+ }
+
public void testBug339025_distinctValuesOnNodeSequence() throws Exception {
// bug 339025
URL fileURL = bundle.getEntry("/bugTestFiles/bug339025.xml");