use of org.sirix.axis.filter.NestedFilter 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.NestedFilter in project sirix by sirixdb.
the class XPathParser method parsePITest.
/**
* Parses the the rule PITest according to the following production rule:
* <p>
* [58] PITest ::= <"processing-instruction" "("> (NCName | StringLiteral)? ")" .
* </p>
*
* @return filter
*/
private Filter parsePITest() {
consume("processing-instruction", true);
consume(TokenType.OPEN_BR, true);
Filter filter = new PIFilter(getTransaction());
if (!is(TokenType.CLOSE_BR, true)) {
String stringLiteral;
if (isQuote()) {
final byte[] param = ((ValueNode) getTransaction().getItemList().getItem(parseStringLiteral()).get()).getRawValue();
stringLiteral = Arrays.toString(param);
} else {
stringLiteral = parseNCName();
}
consume(TokenType.CLOSE_BR, true);
filter = new NestedFilter(getTransaction(), filter, new NameFilter(getTransaction(), stringLiteral));
}
return filter;
}
use of org.sirix.axis.filter.NestedFilter 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.NestedFilter 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;
}
use of org.sirix.axis.filter.NestedFilter in project sirix by sirixdb.
the class XPathParser method parseDocumentTest.
/**
* Parses the the rule DocumentCreater according to the following production rule:
* <p>
* [55] DocumentCreater ::= <"document-node" "("> (ElementTest | SchemaElementTest)? ")" .
* <p>
*
* @return filter
*/
private Filter parseDocumentTest() {
consume("document-node", true);
consume(TokenType.OPEN_BR, true);
Filter filter = new DocumentRootNodeFilter(getTransaction());
Filter innerFilter;
if (mToken.getContent().equals("element")) {
innerFilter = parseElementTest();
filter = new NestedFilter(getTransaction(), filter, innerFilter);
} else if (mToken.getContent().equals("schema-element")) {
innerFilter = parseSchemaElementTest();
filter = new NestedFilter(getTransaction(), filter, innerFilter);
}
consume(TokenType.CLOSE_BR, true);
return filter;
}
Aggregations