Search in sources :

Example 1 with ElementFilter

use of org.sirix.axis.filter.ElementFilter in project sirix by sirixdb.

the class XPathParser method parseWildcard.

/**
 * Parses the the rule Wildcard according to the following production rule:
 * <p>
 * [37] Wildcard ::= "*" | < NCName ":" "*" > | < "*" ":" NCName > .
 * <p>
 *
 * @param pIsAtt Attribute
 * @return filter
 */
private Filter parseWildcard(final boolean pIsAtt) {
    Filter filter;
    EType isName = EType.PREFIX;
    if (is(TokenType.STAR, true)) {
        if (is(TokenType.COLON, true)) {
            // < "*" ":" NCName > .
            isName = EType.LOCALNAME;
        } else {
            return // "*"
            pIsAtt ? new AttributeFilter(getTransaction()) : new ElementFilter(getTransaction());
        }
    }
    filter = new WildcardFilter(getTransaction(), parseNCName(), isName);
    if (isName == EType.PREFIX) {
        // < NCName ":" "*" >
        consume(TokenType.COLON, true);
        consume(TokenType.STAR, true);
    }
    return filter;
}
Also used : 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) SchemaElementFilter(org.sirix.service.xml.xpath.filter.SchemaElementFilter) ElementFilter(org.sirix.axis.filter.ElementFilter) AttributeFilter(org.sirix.axis.filter.AttributeFilter) SchemaAttributeFilter(org.sirix.service.xml.xpath.filter.SchemaAttributeFilter) EType(org.sirix.axis.filter.WildcardFilter.EType) WildcardFilter(org.sirix.axis.filter.WildcardFilter)

Example 2 with ElementFilter

use of org.sirix.axis.filter.ElementFilter in project sirix by sirixdb.

the class NestedFilterTest method testFilterConvetions.

@Test
public void testFilterConvetions() throws SirixException {
    holder.getReader().moveTo(9L);
    FilterTest.testFilterConventions(new NestedFilter(holder.getReader(), new ItemFilter(holder.getReader()), new ElementFilter(holder.getReader()), new NameFilter(holder.getReader(), "b")), true);
    FilterTest.testFilterConventions(new NestedFilter(holder.getReader(), new ItemFilter(holder.getReader()), new AttributeFilter(holder.getReader()), new NameFilter(holder.getReader(), "b")), false);
    holder.getReader().moveTo(4L);
    FilterTest.testFilterConventions(new NestedFilter(holder.getReader(), new NodeFilter(holder.getReader()), new ElementFilter(holder.getReader())), false);
    FilterTest.testFilterConventions(new NestedFilter(holder.getReader(), new NodeFilter(holder.getReader()), new TextFilter(holder.getReader())), true);
    holder.getReader().moveTo(1L);
    holder.getReader().moveToAttribute(0);
    FilterTest.testFilterConventions(new NestedFilter(holder.getReader(), new AttributeFilter(holder.getReader()), new NameFilter(holder.getReader(), "i")), true);
}
Also used : NestedFilter(org.sirix.axis.filter.NestedFilter) NameFilter(org.sirix.axis.filter.NameFilter) TextFilter(org.sirix.axis.filter.TextFilter) ItemFilter(org.sirix.axis.filter.ItemFilter) ElementFilter(org.sirix.axis.filter.ElementFilter) AttributeFilter(org.sirix.axis.filter.AttributeFilter) NodeFilter(org.sirix.axis.filter.NodeFilter) FilterTest(org.sirix.axis.filter.FilterTest) Test(org.junit.Test)

Example 3 with ElementFilter

use of org.sirix.axis.filter.ElementFilter in project sirix by sirixdb.

the class XPathParser method parseElementTest.

// /**
// * Parses the the rule AttributeDeclaration according to the following
// * production rule:
// * <p>
// * [62] AttributeDeclaration ::= AttributeName .
// * </p>
// */
// private String parseAttributeDeclaration() {
// 
// return parseAttributeName();
// }
/**
 * Parses the the rule ElementTest according to the following production rule:
 * <p>
 * [63] ElementTest ::= <"element" "("> (ElementNameOrWildcard ("," TypeName "?"?)?)? ")" .
 * </p>
 *
 * @return filter
 */
private Filter parseElementTest() {
    consume("element", true);
    consume(TokenType.OPEN_BR, true);
    Filter filter = new ElementFilter(getTransaction());
    if (!(mToken.getType() == TokenType.CLOSE_BR)) {
        final String mName = parseElementNameOrWildcard();
        if (!mName.equals("*")) {
            filter = new NestedFilter(getTransaction(), filter, new NameFilter(getTransaction(), mName));
        }
        if (is(TokenType.COMMA, true)) {
            filter = new NestedFilter(getTransaction(), filter, new TypeFilter(getTransaction(), parseTypeName()));
            if (is(TokenType.INTERROGATION, true)) {
                // be false
                throw new NoSuchElementException("'?' is not supported yet.");
            }
        }
    }
    consume(TokenType.CLOSE_BR, true);
    return filter;
}
Also used : NestedFilter(org.sirix.axis.filter.NestedFilter) NameFilter(org.sirix.axis.filter.NameFilter) 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) SchemaElementFilter(org.sirix.service.xml.xpath.filter.SchemaElementFilter) ElementFilter(org.sirix.axis.filter.ElementFilter) TypeFilter(org.sirix.axis.filter.TypeFilter) NoSuchElementException(java.util.NoSuchElementException)

Aggregations

AttributeFilter (org.sirix.axis.filter.AttributeFilter)3 ElementFilter (org.sirix.axis.filter.ElementFilter)3 ItemFilter (org.sirix.axis.filter.ItemFilter)3 NameFilter (org.sirix.axis.filter.NameFilter)3 NestedFilter (org.sirix.axis.filter.NestedFilter)3 NodeFilter (org.sirix.axis.filter.NodeFilter)3 TextFilter (org.sirix.axis.filter.TextFilter)3 Filter (org.sirix.api.Filter)2 CommentFilter (org.sirix.axis.filter.CommentFilter)2 DocumentRootNodeFilter (org.sirix.axis.filter.DocumentRootNodeFilter)2 PIFilter (org.sirix.axis.filter.PIFilter)2 TypeFilter (org.sirix.axis.filter.TypeFilter)2 WildcardFilter (org.sirix.axis.filter.WildcardFilter)2 SchemaAttributeFilter (org.sirix.service.xml.xpath.filter.SchemaAttributeFilter)2 SchemaElementFilter (org.sirix.service.xml.xpath.filter.SchemaElementFilter)2 NoSuchElementException (java.util.NoSuchElementException)1 Test (org.junit.Test)1 FilterTest (org.sirix.axis.filter.FilterTest)1 EType (org.sirix.axis.filter.WildcardFilter.EType)1