Search in sources :

Example 51 with NodeImpl

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

the class ArrayListValueSequence method getPreceding.

@Override
public Sequence getPreceding(final NodeTest test, final int position) throws XPathException {
    final ArrayListValueSequence nodes = new ArrayListValueSequence();
    for (final Item value : values) {
        final NodeImpl node = (NodeImpl) value;
        node.selectPreceding(test, nodes, position);
    }
    return nodes;
}
Also used : NodeImpl(org.exist.dom.memtree.NodeImpl)

Example 52 with NodeImpl

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

the class ArrayListValueSequence method getAncestors.

@Override
public Sequence getAncestors(final boolean includeSelf, final NodeTest test) throws XPathException {
    final ArrayListValueSequence nodes = new ArrayListValueSequence();
    for (final Item value : values) {
        final NodeImpl node = (NodeImpl) value;
        node.selectAncestors(includeSelf, test, nodes);
    }
    return nodes;
}
Also used : NodeImpl(org.exist.dom.memtree.NodeImpl)

Example 53 with NodeImpl

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

the class Utils method nodeFromString.

public static NodeImpl nodeFromString(XQueryContext context, String source) throws IOException {
    SAXAdapter adapter = new SAXAdapter(context);
    final XMLReaderPool parserPool = context.getBroker().getBrokerPool().getParserPool();
    XMLReader xr = null;
    try {
        try {
            xr = parserPool.borrowXMLReader();
            xr.setContentHandler(adapter);
            xr.setProperty(Namespaces.SAX_LEXICAL_HANDLER, adapter);
        } catch (Exception e) {
            throw new IOException(e);
        }
        try {
            InputSource src = new InputSource(new StringReader(source));
            xr.parse(src);
            return (NodeImpl) adapter.getDocument();
        } catch (SAXException e) {
            throw new IOException(e);
        }
    } finally {
        if (xr != null) {
            parserPool.returnXMLReader(xr);
        }
    }
}
Also used : InputSource(org.xml.sax.InputSource) NodeImpl(org.exist.dom.memtree.NodeImpl) StringReader(java.io.StringReader) SAXAdapter(org.exist.dom.memtree.SAXAdapter) IOException(java.io.IOException) XMLReaderPool(org.exist.util.XMLReaderPool) XMLReader(org.xml.sax.XMLReader) SAXException(org.xml.sax.SAXException) IOException(java.io.IOException) SAXException(org.xml.sax.SAXException)

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