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;
}
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);
}
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;
}
Aggregations