use of org.sirix.axis.FollowingSiblingAxis in project sirix by sirixdb.
the class ExpressionSingle method isDupOrd.
/**
* Determines for a given string representation of an axis, whether this axis leads to duplicates
* in the result sequence or not. Furthermore it determines the new state for the order state that
* specifies, if the result sequence is in document order. This method is implemented according to
* the automata in [Hidders, J., Michiels, P., "Avoiding Unnecessary Ordering Operations in
* XPath", 2003]
*
* @param ax name of the current axis
* @return true, if expression is still duplicate free
*/
public boolean isDupOrd(final Axis ax) {
Axis axis = ax;
while (axis instanceof FilterAxis) {
axis = ((FilterAxis) axis).getAxis();
}
if (axis instanceof UnionAxis) {
mOrd = mOrd.updateOrdUnion();
mDup = mDup.updateUnion();
} else if (axis instanceof ChildAxis) {
mOrd = mOrd.updateOrdChild();
mDup = mDup.updateDupChild();
} else if (axis instanceof ParentAxis) {
mOrd = mOrd.updateOrdParent();
mDup = mDup.updateDupParent();
} else if (axis instanceof DescendantAxis) {
mOrd = mOrd.updateOrdDesc();
mDup = mDup.updateDupDesc();
} else if (axis instanceof AncestorAxis) {
mOrd = mOrd.updateOrdAncestor();
mDup = mDup.updateDupAncestor();
} else if (axis instanceof FollowingAxis || axis instanceof PrecedingAxis) {
mOrd = mOrd.updateOrdFollPre();
mDup = mDup.updateDupFollPre();
} else if (axis instanceof FollowingSiblingAxis || axis instanceof PrecedingSiblingAxis) {
mOrd = mOrd.updateOrdFollPreSib();
mDup = mDup.updateDupFollPreSib();
}
return !DupState.nodup;
}
use of org.sirix.axis.FollowingSiblingAxis in project sirix by sirixdb.
the class XPathParser method parseForwardAxis.
/**
* Parses the the rule ForwardAxis according to the following production rule:
* <p>
* [30] ForwardAxis ::= <"child" "::"> | <"descendant" "::"> | <"attribute" "::"> | <"self" "::">
* | <"descendant-or-self" "::"> | <"following-sibling" "::"> | <"following" "::"> | <"namespace"
* "::"> .
* </p>
*
* @return axis
* @throws SirixXPathException
*/
private Axis parseForwardAxis() throws SirixXPathException {
final Axis axis;
if (is("child", true)) {
axis = new ChildAxis(getTransaction());
} else if (is("descendant", true)) {
axis = new DescendantAxis(getTransaction());
} else if (is("descendant-or-self", true)) {
axis = new DescendantAxis(getTransaction(), IncludeSelf.YES);
} else if (is("attribute", true)) {
axis = new AttributeAxis(getTransaction());
} else if (is("self", true)) {
axis = new SelfAxis(getTransaction());
} else if (is("following", true)) {
axis = new FollowingAxis(getTransaction());
} else if (is("following-sibling", true)) {
axis = new FollowingSiblingAxis(getTransaction());
} else {
is("namespace", true);
throw EXPathError.XPST0010.getEncapsulatedException();
}
consume(TokenType.COLON, true);
consume(TokenType.COLON, true);
return axis;
}
use of org.sirix.axis.FollowingSiblingAxis in project sirix by sirixdb.
the class ExpressionSingleTest method testDup.
@Test
public void testDup() throws SirixException {
ExpressionSingle builder = new ExpressionSingle();
builder.add(new ChildAxis(holder.getReader()));
builder.add(new DescendantAxis(holder.getReader()));
assertTrue(builder.getExpr() instanceof NestedAxis);
builder = new ExpressionSingle();
builder.add(new ChildAxis(holder.getReader()));
builder.add(new DescendantAxis(holder.getReader()));
assertEquals(true, builder.isOrdered());
assertTrue(builder.getExpr() instanceof NestedAxis);
builder = new ExpressionSingle();
builder.add(new ChildAxis(holder.getReader()));
builder.add(new DescendantAxis(holder.getReader()));
builder.add(new ChildAxis(holder.getReader()));
assertEquals(false, builder.isOrdered());
builder = new ExpressionSingle();
builder = new ExpressionSingle();
builder.add(new ChildAxis(holder.getReader()));
builder.add(new DescendantAxis(holder.getReader()));
builder.add(new ChildAxis(holder.getReader()));
builder.add(new ParentAxis(holder.getReader()));
assertEquals(true, builder.isOrdered());
builder = new ExpressionSingle();
builder.add(new ChildAxis(holder.getReader()));
builder.add(new DescendantAxis(holder.getReader()));
builder.add(new FollowingSiblingAxis(holder.getReader()));
assertEquals(false, builder.isOrdered());
builder = new ExpressionSingle();
builder.add(new UnionAxis(holder.getReader(), new DescendantAxis(holder.getReader()), new ParentAxis(holder.getReader())));
assertEquals(false, builder.isOrdered());
assertTrue(builder.getExpr() instanceof DupFilterAxis);
}
Aggregations