anc = anc.getParent();
}
break;
}
default:
throw new XPathException("Unsupported axis " + Axis.axisName[upwardsAxis] + " in pattern");
}
}
if (specialFilter) {
if (firstElementPattern) {
SequenceIterator iter = node.iterateAxis(Axis.PRECEDING_SIBLING, nodeTest);
return iter.next() == null;
}
if (lastElementPattern) {
SequenceIterator iter = node.iterateAxis(Axis.FOLLOWING_SIBLING, nodeTest);
return iter.next() == null;
}
if (equivalentExpr != null) {
// for a positional pattern, we do it the hard way: test whether the
// node is a member of the nodeset obtained by evaluating the
// equivalent expression
// System.err.println("Testing positional pattern against node " + node.generateId());
XPathContext c2 = context.newMinorContext();
UnfailingIterator single = SingletonIterator.makeIterator(node);
single.next();
c2.setCurrentIterator(single);
try {
SequenceIterator nsv = equivalentExpr.iterate(c2);
while (true) {
NodeInfo n = (NodeInfo) nsv.next();
if (n == null) {
return false;
}
if (n.isSameNodeInfo(node)) {
return true;
}
}
} catch (XPathException e) {
XPathException err = new XPathException("An error occurred matching pattern {" + toString() + "}: ", e);
err.setXPathContext(c2);
err.setErrorCodeQName(e.getErrorCodeQName());
err.setLocator(this);
c2.getController().recoverableError(err);
return false;
}
}
}
if (filters.length != 0) {
XPathContext c2 = context.newMinorContext();
UnfailingIterator iter = SingletonIterator.makeIterator(node);
iter.next();
c2.setCurrentIterator(iter);
// it's a non-positional filter, so we can handle each node separately
for (int i = 0; i < filters.length; i++) {
try {
if (!filters[i].effectiveBooleanValue(c2)) {
return false;
}
} catch (XPathException e) {
if ("XTDE0640".equals(e.getErrorCodeLocalPart())) {
// Treat circularity error as fatal (test error213)
throw e;
}
XPathException err = new XPathException("An error occurred matching pattern {" + toString() + "}: ", e);
err.setXPathContext(c2);
err.setErrorCodeQName(e.getErrorCodeQName());
err.setLocator(this);
c2.getController().recoverableError(err);
return false;
}
}
}