Search in sources :

Example 16 with FilterAxis

use of org.sirix.axis.filter.FilterAxis 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)

Example 17 with FilterAxis

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

the class NodeWrapper method expandString.

/**
 * Filter text nodes.
 *
 * @return concatenated String of text node values
 */
private String expandString() {
    final FastStringBuffer fsb = new FastStringBuffer(FastStringBuffer.SMALL);
    try {
        final NodeReadTrx rtx = createRtxAndMove();
        final FilterAxis axis = new FilterAxis(new DescendantAxis(rtx), new TextFilter(rtx));
        while (axis.hasNext()) {
            axis.next();
            fsb.append(rtx.getValue());
        }
        rtx.close();
    } catch (final SirixException exc) {
        LOGGER.error(exc.toString());
    }
    return fsb.condense().toString();
}
Also used : TextFilter(org.sirix.axis.filter.TextFilter) FastStringBuffer(net.sf.saxon.tree.util.FastStringBuffer) NodeReadTrx(org.sirix.api.NodeReadTrx) SirixException(org.sirix.exception.SirixException) DescendantAxis(org.sirix.axis.DescendantAxis) FilterAxis(org.sirix.axis.filter.FilterAxis)

Aggregations

FilterAxis (org.sirix.axis.filter.FilterAxis)17 DescendantAxis (org.sirix.axis.DescendantAxis)13 NameFilter (org.sirix.axis.filter.NameFilter)13 Axis (org.sirix.api.Axis)12 ChildAxis (org.sirix.axis.ChildAxis)10 Test (org.junit.Test)7 XdmNodeReadTrx (org.sirix.api.XdmNodeReadTrx)7 NestedAxis (org.sirix.axis.NestedAxis)5 TextFilter (org.sirix.axis.filter.TextFilter)5 LevelOrderAxis (org.sirix.axis.LevelOrderAxis)4 PostOrderAxis (org.sirix.axis.PostOrderAxis)4 PathKindFilter (org.sirix.axis.filter.PathKindFilter)4 UnorderedKeyValuePage (org.sirix.page.UnorderedKeyValuePage)4 XPathAxis (org.sirix.service.xml.xpath.XPathAxis)4 XMLStreamException (javax.xml.stream.XMLStreamException)2 NodeReadTrx (org.sirix.api.NodeReadTrx)2 NodeFilter (org.sirix.axis.filter.NodeFilter)2 PathLevelFilter (org.sirix.axis.filter.PathLevelFilter)2 ElementNode (org.sirix.node.ElementNode)2 NameNode (org.sirix.node.interfaces.NameNode)2