Search in sources :

Example 6 with NodeListImpl

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

the class ElementImpl method getChildNodes.

@Override
public NodeList getChildNodes() {
    // nil elements are rare, so we use 1 here
    final NodeListImpl nl = new NodeListImpl(1);
    int nextNode = document.getFirstChildFor(nodeNumber);
    while (nextNode > nodeNumber) {
        final Node n = document.getNode(nextNode);
        if (n.getNodeType() != Node.ATTRIBUTE_NODE) {
            nl.add(n);
        }
        nextNode = document.next[nextNode];
    }
    return nl;
}
Also used : NodeListImpl(org.exist.dom.NodeListImpl)

Example 7 with NodeListImpl

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

the class ElementImpl method getElementsByTagName.

private NodeList getElementsByTagName(final QName qname) {
    final NodeListImpl nl = new NodeListImpl();
    int nextNode = nodeNumber;
    final int treeLevel = document.treeLevel[nodeNumber];
    while (++nextNode < document.size && document.treeLevel[nextNode] > treeLevel) {
        if (document.nodeKind[nextNode] == Node.ELEMENT_NODE) {
            final QName qn = document.nodeName[nextNode];
            if (qname.matches(qn)) {
                nl.add(document.getNode(nextNode));
            }
        }
    }
    return nl;
}
Also used : NodeListImpl(org.exist.dom.NodeListImpl) QName(org.exist.dom.QName)

Aggregations

NodeListImpl (org.exist.dom.NodeListImpl)7 Item (org.exist.xquery.value.Item)3 SequenceIterator (org.exist.xquery.value.SequenceIterator)3 XPathException (org.exist.xquery.XPathException)2 Sequence (org.exist.xquery.value.Sequence)2 Node (org.w3c.dom.Node)2 EXistException (org.exist.EXistException)1 TriggerException (org.exist.collections.triggers.TriggerException)1 QName (org.exist.dom.QName)1 AttrImpl (org.exist.dom.persistent.AttrImpl)1 DocumentImpl (org.exist.dom.persistent.DocumentImpl)1 ElementImpl (org.exist.dom.persistent.ElementImpl)1 StoredNode (org.exist.dom.persistent.StoredNode)1 TextImpl (org.exist.dom.persistent.TextImpl)1 NotificationService (org.exist.storage.NotificationService)1 Txn (org.exist.storage.txn.Txn)1 LockException (org.exist.util.LockException)1 NodeValue (org.exist.xquery.value.NodeValue)1 StringValue (org.exist.xquery.value.StringValue)1 ValueSequence (org.exist.xquery.value.ValueSequence)1