Search in sources :

Example 1 with AttributeAxis

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

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

the class FilterAxisTest method testValueAndNameAxisTest.

@Test
public void testValueAndNameAxisTest() throws SirixException {
    final XdmNodeReadTrx rtx = holder.getReader();
    rtx.moveTo(1L);
    AbsAxisTest.testIAxisConventions(new FilterAxis(new AttributeAxis(rtx), new NameFilter(rtx, "i"), new ValueFilter(rtx, "j")), new long[] { 3L });
    rtx.moveTo(9L);
    AbsAxisTest.testIAxisConventions(new FilterAxis(new AttributeAxis(rtx), new NameFilter(rtx, "y"), new ValueFilter(rtx, "y")), new long[] {});
}
Also used : XdmNodeReadTrx(org.sirix.api.XdmNodeReadTrx) AttributeAxis(org.sirix.axis.AttributeAxis) Test(org.junit.Test) AbsAxisTest(org.sirix.axis.AbsAxisTest)

Example 3 with AttributeAxis

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

the class XPathParser method parseAbbrevForwardStep.

/**
 * Parses the the rule AbrevForwardStep according to the following production rule:
 * <p>
 * [31] AbbrevForwardStep ::= "@"? NodeTest .
 * </p>
 *
 * @return FilterAxis
 */
private AbstractAxis parseAbbrevForwardStep() {
    AbstractAxis axis;
    boolean isAttribute;
    if (is(TokenType.AT, true) || mToken.getContent().equals("attribute") || mToken.getContent().equals("schema-attribute")) {
        // in case of .../attribute(..), or .../schema-attribute() the
        // default
        // axis
        // is the attribute axis
        axis = new AttributeAxis(getTransaction());
        isAttribute = true;
    } else {
        // default axis is the child axis
        axis = new ChildAxis(getTransaction());
        isAttribute = false;
    }
    final Filter filter = parseNodeTest(isAttribute);
    return new FilterAxis(axis, filter);
}
Also used : ChildAxis(org.sirix.axis.ChildAxis) ItemFilter(org.sirix.axis.filter.ItemFilter) AttributeFilter(org.sirix.axis.filter.AttributeFilter) NameFilter(org.sirix.axis.filter.NameFilter) TypeFilter(org.sirix.axis.filter.TypeFilter) NestedFilter(org.sirix.axis.filter.NestedFilter) DocumentRootNodeFilter(org.sirix.axis.filter.DocumentRootNodeFilter) CommentFilter(org.sirix.axis.filter.CommentFilter) WildcardFilter(org.sirix.axis.filter.WildcardFilter) PIFilter(org.sirix.axis.filter.PIFilter) SchemaElementFilter(org.sirix.service.xml.xpath.filter.SchemaElementFilter) Filter(org.sirix.api.Filter) SchemaAttributeFilter(org.sirix.service.xml.xpath.filter.SchemaAttributeFilter) TextFilter(org.sirix.axis.filter.TextFilter) ElementFilter(org.sirix.axis.filter.ElementFilter) NodeFilter(org.sirix.axis.filter.NodeFilter) AbstractAxis(org.sirix.axis.AbstractAxis) AttributeAxis(org.sirix.axis.AttributeAxis) FilterAxis(org.sirix.axis.filter.FilterAxis)

Aggregations

AttributeAxis (org.sirix.axis.AttributeAxis)3 AbstractAxis (org.sirix.axis.AbstractAxis)2 ChildAxis (org.sirix.axis.ChildAxis)2 FilterAxis (org.sirix.axis.filter.FilterAxis)2 Test (org.junit.Test)1 Axis (org.sirix.api.Axis)1 Filter (org.sirix.api.Filter)1 XdmNodeReadTrx (org.sirix.api.XdmNodeReadTrx)1 AbsAxisTest (org.sirix.axis.AbsAxisTest)1 AncestorAxis (org.sirix.axis.AncestorAxis)1 DescendantAxis (org.sirix.axis.DescendantAxis)1 FollowingAxis (org.sirix.axis.FollowingAxis)1 FollowingSiblingAxis (org.sirix.axis.FollowingSiblingAxis)1 ParentAxis (org.sirix.axis.ParentAxis)1 PrecedingAxis (org.sirix.axis.PrecedingAxis)1 PrecedingSiblingAxis (org.sirix.axis.PrecedingSiblingAxis)1 SelfAxis (org.sirix.axis.SelfAxis)1 AttributeFilter (org.sirix.axis.filter.AttributeFilter)1 CommentFilter (org.sirix.axis.filter.CommentFilter)1 DocumentRootNodeFilter (org.sirix.axis.filter.DocumentRootNodeFilter)1