#459 Document order with namespace nodes

v8.6.1
closed
5
2014-08-19
2006-01-10
Michael Kay
No

Two problems that affect comparisons of document order
between namespace nodes and nodes other than namespace
nodes.

(a) If $e is an element, then ($e <<
$e/namespace::*[1]) returns false; it should return true.

(b) When using the "standard tree" (NOT the default
TinyTree), any order or identity comparison between a
namespace node and a non-namespace node may throw a
ClassCastException.

Patch for (a): In net.sf.saxon.om.NamespaceIterator,
change the method compareOrder() at line 310 to read:

    public int compareOrder(NodeInfo other) {
        if (other instanceof NamespaceNodeImpl &&

element.isSameNodeInfo(((NamespaceNodeImpl)other).element))
{
// JDK 1.5: return
Integer.signum(position -
((NamespaceNodeI)other).position);
int c = position -
((NamespaceNodeImpl)other).position;
if (c == 0) return 0;
if (c < 0) return -1;
return +1;
} else if (element.isSameNodeInfo(other)) {
return +1;
} else {
return element.compareOrder(other);
}
}

Patch for (b): In net.sf.saxon.tree.NodeImpl, change
the method compareOrder() at line 245 to read:

public final int compareOrder(NodeInfo other) {
    if (other instanceof

NamespaceIterator.NamespaceNodeImpl) {
return 0 - other.compareOrder(this);
}
long a = getSequenceNumber();
long b = ((NodeImpl)other).getSequenceNumber();
if (a < b) {
return -1;
}
if (a > b) {
return +1;
}
return 0;
}

(Extra imports will be needed, not shown)

Discussion

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks