Search in sources :

Example 31 with NodeImpl

use of org.exist.dom.memtree.NodeImpl in project exist by eXist-db.

the class ValueSequence method selectDescendants.

@Override
public Sequence selectDescendants(final MemoryNodeSet descendants) {
    sortInDocumentOrder();
    final ValueSequence nodes = new ValueSequence(true);
    nodes.keepUnOrdered(keepUnOrdered);
    for (int i = 0; i <= size; i++) {
        final NodeImpl node = (NodeImpl) values[i];
        for (int j = 0; j < descendants.size(); j++) {
            final NodeImpl descendant = descendants.get(j);
            if (descendant.getNodeId().isDescendantOrSelfOf(node.getNodeId())) {
                nodes.add(node);
            }
        }
    }
    return nodes;
}
Also used : NodeImpl(org.exist.dom.memtree.NodeImpl)

Example 32 with NodeImpl

use of org.exist.dom.memtree.NodeImpl in project exist by eXist-db.

the class ValueSequence method getParents.

@Override
public Sequence getParents(final NodeTest test) throws XPathException {
    sortInDocumentOrder();
    final ValueSequence nodes = new ValueSequence(true);
    nodes.keepUnOrdered(keepUnOrdered);
    for (int i = 0; i <= size; i++) {
        final NodeImpl node = (NodeImpl) values[i];
        final NodeImpl parent = (NodeImpl) node.selectParentNode();
        if (parent != null && test.matches(parent)) {
            nodes.add(parent);
        }
    }
    return nodes;
}
Also used : NodeImpl(org.exist.dom.memtree.NodeImpl)

Example 33 with NodeImpl

use of org.exist.dom.memtree.NodeImpl in project exist by eXist-db.

the class ValueSequence method getDescendants.

@Override
public Sequence getDescendants(final boolean includeSelf, final NodeTest test) throws XPathException {
    sortInDocumentOrder();
    final ValueSequence nodes = new ValueSequence(true);
    nodes.keepUnOrdered(keepUnOrdered);
    for (int i = 0; i <= size; i++) {
        final NodeImpl node = (NodeImpl) values[i];
        node.selectDescendants(includeSelf, test, nodes);
    }
    return nodes;
}
Also used : NodeImpl(org.exist.dom.memtree.NodeImpl)

Example 34 with NodeImpl

use of org.exist.dom.memtree.NodeImpl in project exist by eXist-db.

the class ValueSequence method getAncestors.

@Override
public Sequence getAncestors(final boolean includeSelf, final NodeTest test) throws XPathException {
    sortInDocumentOrder();
    final ValueSequence nodes = new ValueSequence(true);
    nodes.keepUnOrdered(keepUnOrdered);
    for (int i = 0; i <= size; i++) {
        final NodeImpl node = (NodeImpl) values[i];
        node.selectAncestors(includeSelf, test, nodes);
    }
    return nodes;
}
Also used : NodeImpl(org.exist.dom.memtree.NodeImpl)

Example 35 with NodeImpl

use of org.exist.dom.memtree.NodeImpl in project exist by eXist-db.

the class ValueSequence method getPrecedingSiblings.

@Override
public Sequence getPrecedingSiblings(final NodeTest test) throws XPathException {
    sortInDocumentOrder();
    final ValueSequence nodes = new ValueSequence(true);
    nodes.keepUnOrdered(keepUnOrdered);
    for (int i = 0; i <= size; i++) {
        final NodeImpl node = (NodeImpl) values[i];
        // if the context node is an attribute or namespace node, the preceding-sibling axis is empty
        if (node.getNodeType() != Node.ATTRIBUTE_NODE) {
            node.selectPrecedingSiblings(test, nodes);
        }
    }
    return nodes;
}
Also used : NodeImpl(org.exist.dom.memtree.NodeImpl)

Aggregations

NodeImpl (org.exist.dom.memtree.NodeImpl)53 MemTreeBuilder (org.exist.dom.memtree.MemTreeBuilder)14 XPathException (org.exist.xquery.XPathException)9 DocumentImpl (org.exist.dom.memtree.DocumentImpl)8 Sequence (org.exist.xquery.value.Sequence)8 SAXException (org.xml.sax.SAXException)8 SAXAdapter (org.exist.dom.memtree.SAXAdapter)6 NodeProxy (org.exist.dom.persistent.NodeProxy)6 ValueSequence (org.exist.xquery.value.ValueSequence)6 IOException (java.io.IOException)5 Document (org.w3c.dom.Document)5 InputSource (org.xml.sax.InputSource)5 StringReader (java.io.StringReader)4 QName (org.exist.dom.QName)4 SequenceIterator (org.exist.xquery.value.SequenceIterator)4 XMLReader (org.xml.sax.XMLReader)4 DocumentBuilderReceiver (org.exist.dom.memtree.DocumentBuilderReceiver)3 NodeSet (org.exist.dom.persistent.NodeSet)3 NodeId (org.exist.numbering.NodeId)3 ValidationReport (org.exist.validation.ValidationReport)3