Search in sources :

Example 1 with SelfAxis

use of org.sirix.axis.SelfAxis 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)

Example 2 with SelfAxis

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

the class ExpressionSingleTest method testAdd.

@Test
public void testAdd() throws SirixException {
    // Verify.
    final ExpressionSingle builder = new ExpressionSingle();
    // test one axis
    AbstractAxis self = new SelfAxis(holder.getReader());
    builder.add(self);
    assertEquals(builder.getExpr(), self);
    // test 2 axis
    AbstractAxis axis1 = new SelfAxis(holder.getReader());
    AbstractAxis axis2 = new SelfAxis(holder.getReader());
    builder.add(axis1);
    builder.add(axis2);
    assertTrue(builder.getExpr() instanceof NestedAxis);
}
Also used : SelfAxis(org.sirix.axis.SelfAxis) AbstractAxis(org.sirix.axis.AbstractAxis) NestedAxis(org.sirix.axis.NestedAxis) Test(org.junit.Test)

Example 3 with SelfAxis

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

the class XPathParser method parseContextItemExpr.

/**
 * Parses the the rule ContextItemExpr according to the following production rule:
 * <p>
 * [46] ContextItemExpr ::= "." .
 * </p>
 */
private void parseContextItemExpr() {
    consume(TokenType.POINT, true);
    mPipeBuilder.addStep(new SelfAxis(getTransaction()));
}
Also used : SelfAxis(org.sirix.axis.SelfAxis)

Aggregations

SelfAxis (org.sirix.axis.SelfAxis)3 AbstractAxis (org.sirix.axis.AbstractAxis)2 Test (org.junit.Test)1 Axis (org.sirix.api.Axis)1 AncestorAxis (org.sirix.axis.AncestorAxis)1 AttributeAxis (org.sirix.axis.AttributeAxis)1 ChildAxis (org.sirix.axis.ChildAxis)1 DescendantAxis (org.sirix.axis.DescendantAxis)1 FollowingAxis (org.sirix.axis.FollowingAxis)1 FollowingSiblingAxis (org.sirix.axis.FollowingSiblingAxis)1 NestedAxis (org.sirix.axis.NestedAxis)1 ParentAxis (org.sirix.axis.ParentAxis)1 PrecedingAxis (org.sirix.axis.PrecedingAxis)1 PrecedingSiblingAxis (org.sirix.axis.PrecedingSiblingAxis)1 FilterAxis (org.sirix.axis.filter.FilterAxis)1 DocumentNodeAxis (org.sirix.service.xml.xpath.filter.DocumentNodeAxis)1