Search in sources :

Example 1 with FollowingAxis

use of org.sirix.axis.FollowingAxis 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;
}
Also used : ChildAxis(org.sirix.axis.ChildAxis) AncestorAxis(org.sirix.axis.AncestorAxis) FollowingSiblingAxis(org.sirix.axis.FollowingSiblingAxis) FollowingAxis(org.sirix.axis.FollowingAxis) PrecedingAxis(org.sirix.axis.PrecedingAxis) PrecedingSiblingAxis(org.sirix.axis.PrecedingSiblingAxis) ParentAxis(org.sirix.axis.ParentAxis) DescendantAxis(org.sirix.axis.DescendantAxis) AncestorAxis(org.sirix.axis.AncestorAxis) PrecedingAxis(org.sirix.axis.PrecedingAxis) Axis(org.sirix.api.Axis) NestedAxis(org.sirix.axis.NestedAxis) ChildAxis(org.sirix.axis.ChildAxis) FollowingSiblingAxis(org.sirix.axis.FollowingSiblingAxis) UnionAxis(org.sirix.service.xml.xpath.expr.UnionAxis) FollowingAxis(org.sirix.axis.FollowingAxis) FilterAxis(org.sirix.axis.filter.FilterAxis) DescendantAxis(org.sirix.axis.DescendantAxis) ParentAxis(org.sirix.axis.ParentAxis) DupFilterAxis(org.sirix.service.xml.xpath.filter.DupFilterAxis) PrecedingSiblingAxis(org.sirix.axis.PrecedingSiblingAxis) FilterAxis(org.sirix.axis.filter.FilterAxis) DupFilterAxis(org.sirix.service.xml.xpath.filter.DupFilterAxis) UnionAxis(org.sirix.service.xml.xpath.expr.UnionAxis)

Example 2 with FollowingAxis

use of org.sirix.axis.FollowingAxis in project sirix by sirixdb.

the class DBNode method isPrecedingOf.

@Override
public boolean isPrecedingOf(final Node<?> other) {
    if (other instanceof DBNode) {
        final DBNode node = (DBNode) other;
        moveRtx();
        if (mKind != org.sirix.node.Kind.ATTRIBUTE && mKind != org.sirix.node.Kind.NAMESPACE) {
            if (mDeweyID.isPresent()) {
                return mDeweyID.get().isPrecedingOf(node.mDeweyID.get());
            } else {
                for (final Axis axis = new FollowingAxis(mRtx); axis.hasNext(); ) {
                    axis.next();
                    if (mRtx.getNodeKey() == node.getNodeKey()) {
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
Also used : FollowingAxis(org.sirix.axis.FollowingAxis) AllTimeAxis(org.sirix.axis.temporal.AllTimeAxis) PrecedingAxis(org.sirix.axis.PrecedingAxis) Axis(org.sirix.api.Axis) FirstAxis(org.sirix.axis.temporal.FirstAxis) AbstractTemporalAxis(org.sirix.axis.AbstractTemporalAxis) ChildAxis(org.sirix.axis.ChildAxis) LastAxis(org.sirix.axis.temporal.LastAxis) AttributeAxis(org.sirix.axis.AttributeAxis) PastAxis(org.sirix.axis.temporal.PastAxis) FollowingAxis(org.sirix.axis.FollowingAxis) AncestorAxis(org.sirix.axis.AncestorAxis) FutureAxis(org.sirix.axis.temporal.FutureAxis) NonStructuralWrapperAxis(org.sirix.axis.NonStructuralWrapperAxis) NextAxis(org.sirix.axis.temporal.NextAxis) PreviousAxis(org.sirix.axis.temporal.PreviousAxis) DescendantAxis(org.sirix.axis.DescendantAxis)

Example 3 with FollowingAxis

use of org.sirix.axis.FollowingAxis 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;
}
Also used : ChildAxis(org.sirix.axis.ChildAxis) SelfAxis(org.sirix.axis.SelfAxis) FollowingSiblingAxis(org.sirix.axis.FollowingSiblingAxis) FollowingAxis(org.sirix.axis.FollowingAxis) AttributeAxis(org.sirix.axis.AttributeAxis) DescendantAxis(org.sirix.axis.DescendantAxis) PrecedingAxis(org.sirix.axis.PrecedingAxis) Axis(org.sirix.api.Axis) DocumentNodeAxis(org.sirix.service.xml.xpath.filter.DocumentNodeAxis) FollowingAxis(org.sirix.axis.FollowingAxis) AbstractAxis(org.sirix.axis.AbstractAxis) AncestorAxis(org.sirix.axis.AncestorAxis) ChildAxis(org.sirix.axis.ChildAxis) FollowingSiblingAxis(org.sirix.axis.FollowingSiblingAxis) FilterAxis(org.sirix.axis.filter.FilterAxis) SelfAxis(org.sirix.axis.SelfAxis) DescendantAxis(org.sirix.axis.DescendantAxis) ParentAxis(org.sirix.axis.ParentAxis) AttributeAxis(org.sirix.axis.AttributeAxis) PrecedingSiblingAxis(org.sirix.axis.PrecedingSiblingAxis)

Aggregations

Axis (org.sirix.api.Axis)3 AncestorAxis (org.sirix.axis.AncestorAxis)3 ChildAxis (org.sirix.axis.ChildAxis)3 DescendantAxis (org.sirix.axis.DescendantAxis)3 FollowingAxis (org.sirix.axis.FollowingAxis)3 PrecedingAxis (org.sirix.axis.PrecedingAxis)3 AttributeAxis (org.sirix.axis.AttributeAxis)2 FollowingSiblingAxis (org.sirix.axis.FollowingSiblingAxis)2 ParentAxis (org.sirix.axis.ParentAxis)2 PrecedingSiblingAxis (org.sirix.axis.PrecedingSiblingAxis)2 FilterAxis (org.sirix.axis.filter.FilterAxis)2 AbstractAxis (org.sirix.axis.AbstractAxis)1 AbstractTemporalAxis (org.sirix.axis.AbstractTemporalAxis)1 NestedAxis (org.sirix.axis.NestedAxis)1 NonStructuralWrapperAxis (org.sirix.axis.NonStructuralWrapperAxis)1 SelfAxis (org.sirix.axis.SelfAxis)1 AllTimeAxis (org.sirix.axis.temporal.AllTimeAxis)1 FirstAxis (org.sirix.axis.temporal.FirstAxis)1 FutureAxis (org.sirix.axis.temporal.FutureAxis)1 LastAxis (org.sirix.axis.temporal.LastAxis)1