use of org.sirix.axis.filter.AttributeFilter in project sirix by sirixdb.
the class XPathParser method parseAttributeTest.
/**
* Parses the the rule AttributeTest according to the following production rule:
* <p>
* [59] AttributeTest ::= <"attribute" "("> (AttribNameOrWildcard ("," TypeName)?)? ")" .
* </p>
*
* @return filter
*/
private Filter parseAttributeTest() {
consume("attribute", true);
consume(TokenType.OPEN_BR, true);
Filter filter = new AttributeFilter(getTransaction());
if (!(mToken.getType() == TokenType.CLOSE_BR)) {
// add name filter
final String name = parseAttributeNameOrWildcard();
if (!name.equals("*")) {
filter = new NestedFilter(getTransaction(), filter, new NameFilter(getTransaction(), name));
}
if (is(TokenType.COMMA, true)) {
// add type filter
filter = new NestedFilter(getTransaction(), filter, new TypeFilter(getTransaction(), parseTypeName()));
}
}
consume(TokenType.CLOSE_BR, true);
return filter;
}
use of org.sirix.axis.filter.AttributeFilter 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;
}
use of org.sirix.axis.filter.AttributeFilter 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);
}
Aggregations