Search in sources :

Example 1 with NodeSelector

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

the class MoveOverwriteCollectionTest 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);
    assertTrue(nodes.isEmpty());
    nodes = index.findElementsByTagName(ELEMENT, docs, new QName("test3"), selector);
    assertFalse(nodes.isEmpty());
}
Also used : StructuralIndex(org.exist.indexing.StructuralIndex) QName(org.exist.dom.QName) NodeSelector(org.exist.xquery.NodeSelector)

Example 2 with NodeSelector

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

the class BasicNodeSetTest method descendantOrSelfSelector.

@Test
public void descendantOrSelfSelector() throws XPathException, EXistException {
    NodeSelector selector = new DescendantOrSelfSelector(seqSpeech.toNodeSet(), -1);
    NameTest test = new NameTest(Type.ELEMENT, new QName("SPEECH", ""));
    try (final DBBroker broker = existEmbeddedServer.getBrokerPool().get(Optional.of(existEmbeddedServer.getBrokerPool().getSecurityManager().getSystemSubject()))) {
        NodeSet set = broker.getStructuralIndex().findElementsByTagName(ElementValue.ELEMENT, seqSpeech.getDocumentSet(), test.getName(), selector);
        assertEquals(2628, set.getLength());
    }
}
Also used : NameTest(org.exist.xquery.NameTest) DBBroker(org.exist.storage.DBBroker) QName(org.exist.dom.QName) NodeSelector(org.exist.xquery.NodeSelector) DescendantOrSelfSelector(org.exist.xquery.DescendantOrSelfSelector) Test(org.junit.Test) NameTest(org.exist.xquery.NameTest)

Example 3 with NodeSelector

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

the class BasicNodeSetTest method ancestorSelector_self.

@Test
public void ancestorSelector_self() throws XPathException, EXistException {
    NodeSet ns = seqSpeech.toNodeSet();
    NodeSelector selector = new AncestorSelector(ns, -1, true, true);
    NameTest test = new NameTest(Type.ELEMENT, new QName("SPEECH", ""));
    try (final DBBroker broker = existEmbeddedServer.getBrokerPool().get(Optional.of(existEmbeddedServer.getBrokerPool().getSecurityManager().getSystemSubject()))) {
        NodeSet set = broker.getStructuralIndex().findElementsByTagName(ElementValue.ELEMENT, seqSpeech.getDocumentSet(), test.getName(), selector);
        assertEquals(2628, set.getLength());
    }
}
Also used : NameTest(org.exist.xquery.NameTest) DBBroker(org.exist.storage.DBBroker) AncestorSelector(org.exist.xquery.AncestorSelector) QName(org.exist.dom.QName) NodeSelector(org.exist.xquery.NodeSelector) Test(org.junit.Test) NameTest(org.exist.xquery.NameTest)

Example 4 with NodeSelector

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

the class BasicNodeSetTest method childSelector.

@Test
public void childSelector() throws XPathException, EXistException {
    NodeSelector selector = new ChildSelector(seqSpeech.toNodeSet(), -1);
    NameTest test = new NameTest(Type.ELEMENT, new QName("LINE", ""));
    try (final DBBroker broker = existEmbeddedServer.getBrokerPool().get(Optional.of(existEmbeddedServer.getBrokerPool().getSecurityManager().getSystemSubject()))) {
        NodeSet set = broker.getStructuralIndex().findElementsByTagName(ElementValue.ELEMENT, seqSpeech.getDocumentSet(), test.getName(), selector);
        assertEquals(9492, set.getLength());
    }
}
Also used : ChildSelector(org.exist.xquery.ChildSelector) NameTest(org.exist.xquery.NameTest) DBBroker(org.exist.storage.DBBroker) QName(org.exist.dom.QName) NodeSelector(org.exist.xquery.NodeSelector) Test(org.junit.Test) NameTest(org.exist.xquery.NameTest)

Example 5 with NodeSelector

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

the class BasicNodeSetTest method ancestorSelector.

@Test
public void ancestorSelector() throws XPathException, EXistException {
    NodeSelector selector = new AncestorSelector(seqSpeech.toNodeSet(), -1, false, true);
    NameTest test = new NameTest(Type.ELEMENT, new QName("ACT", ""));
    try (final DBBroker broker = existEmbeddedServer.getBrokerPool().get(Optional.of(existEmbeddedServer.getBrokerPool().getSecurityManager().getSystemSubject()))) {
        NodeSet set = broker.getStructuralIndex().findElementsByTagName(ElementValue.ELEMENT, seqSpeech.getDocumentSet(), test.getName(), selector);
        assertEquals(15, set.getLength());
    }
}
Also used : NameTest(org.exist.xquery.NameTest) DBBroker(org.exist.storage.DBBroker) AncestorSelector(org.exist.xquery.AncestorSelector) QName(org.exist.dom.QName) NodeSelector(org.exist.xquery.NodeSelector) Test(org.junit.Test) NameTest(org.exist.xquery.NameTest)

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