Search in sources :

Example 6 with NodeSelector

use of org.exist.xquery.NodeSelector in project exist by eXist-db.

the class BasicNodeSetTest method descendantSelector.

@Test
public void descendantSelector() throws XPathException, SAXException, PermissionDeniedException, EXistException {
    try (final DBBroker broker = existEmbeddedServer.getBrokerPool().get(Optional.of(existEmbeddedServer.getBrokerPool().getSecurityManager().getSystemSubject()))) {
        Sequence seq = executeQuery(broker, "//SCENE", 72, null);
        NameTest test = new NameTest(Type.ELEMENT, new QName("SPEAKER", ""));
        NodeSelector selector = new DescendantSelector(seq.toNodeSet(), -1);
        NodeSet set = broker.getStructuralIndex().findElementsByTagName(ElementValue.ELEMENT, seq.getDocumentSet(), test.getName(), selector);
        assertEquals(2639, set.getLength());
    }
}
Also used : DBBroker(org.exist.storage.DBBroker) NameTest(org.exist.xquery.NameTest) QName(org.exist.dom.QName) Sequence(org.exist.xquery.value.Sequence) NodeSelector(org.exist.xquery.NodeSelector) DescendantSelector(org.exist.xquery.DescendantSelector) Test(org.junit.Test) NameTest(org.exist.xquery.NameTest)

Example 7 with NodeSelector

use of org.exist.xquery.NodeSelector in project exist by eXist-db.

the class MoveOverwriteResourceTest method checkIndex.

private void checkIndex(final DBBroker broker, final DocumentSet docs) throws Exception {
    final StructuralIndex index = broker.getStructuralIndex();
    final NodeSelector selector = NodeProxy::new;
    NodeSet nodes;
    nodes = index.findElementsByTagName(ELEMENT, docs, new QName("test2"), selector);
    assertTrue(nodes.isEmpty());
    nodes = index.findElementsByTagName(ELEMENT, docs, new QName("test1"), selector);
    assertFalse(nodes.isEmpty());
}
Also used : QName(org.exist.dom.QName) NodeSelector(org.exist.xquery.NodeSelector)

Aggregations

QName (org.exist.dom.QName)7 NodeSelector (org.exist.xquery.NodeSelector)7 DBBroker (org.exist.storage.DBBroker)5 NameTest (org.exist.xquery.NameTest)5 Test (org.junit.Test)5 AncestorSelector (org.exist.xquery.AncestorSelector)2 StructuralIndex (org.exist.indexing.StructuralIndex)1 ChildSelector (org.exist.xquery.ChildSelector)1 DescendantOrSelfSelector (org.exist.xquery.DescendantOrSelfSelector)1 DescendantSelector (org.exist.xquery.DescendantSelector)1 Sequence (org.exist.xquery.value.Sequence)1