use of org.exist.xquery.NameTest in project exist by eXist-db.
the class BasicNodeSetTest method selectParentChild_2.
@Test
public void selectParentChild_2() throws XPathException, SAXException, PermissionDeniedException, EXistException {
NameTest test = new NameTest(Type.ELEMENT, new QName("SPEAKER", ""));
try (final DBBroker broker = existEmbeddedServer.getBrokerPool().get(Optional.of(existEmbeddedServer.getBrokerPool().getSecurityManager().getSystemSubject()))) {
NodeSet speakers = broker.getStructuralIndex().findElementsByTagName(ElementValue.ELEMENT, docs, test.getName(), null);
Sequence largeSet = executeQuery(broker, "//SPEECH/LINE[fn:contains(., 'love')]/ancestor::SPEECH", 187, null);
NodeSet result = NodeSetHelper.selectParentChild(speakers, largeSet.toNodeSet(), NodeSet.DESCENDANT, -1);
assertEquals(187, result.getLength());
}
}
use of org.exist.xquery.NameTest in project exist by eXist-db.
the class BasicNodeSetTest method nodeProxy_getParents.
@Test
public void nodeProxy_getParents() throws XPathException, SAXException, PermissionDeniedException, EXistException {
try (final DBBroker broker = existEmbeddedServer.getBrokerPool().get(Optional.of(existEmbeddedServer.getBrokerPool().getSecurityManager().getSystemSubject()))) {
Sequence smallSet = executeQuery(broker, "//SPEECH/LINE[fn:contains(., 'perturbed spirit')]/ancestor::SPEECH", 1, null);
NodeProxy proxy = (NodeProxy) smallSet.itemAt(0);
NodeSet result = proxy.getParents(-1);
assertEquals(1, result.getLength());
NameTest test = new NameTest(Type.ELEMENT, new QName("SPEAKER", ""));
NodeSet speakers = broker.getStructuralIndex().findElementsByTagName(ElementValue.ELEMENT, docs, test.getName(), null);
result = speakers.selectParentChild(proxy, NodeSet.DESCENDANT, -1);
assertEquals(1, result.getLength());
}
}
use of org.exist.xquery.NameTest in project exist by eXist-db.
the class BasicNodeSetTest method selectPrecedingSiblings.
@Test
public void selectPrecedingSiblings() throws XPathException, SAXException, PermissionDeniedException, EXistException {
NameTest test = new NameTest(Type.ELEMENT, new QName("SPEAKER", ""));
try (final DBBroker broker = existEmbeddedServer.getBrokerPool().get(Optional.of(existEmbeddedServer.getBrokerPool().getSecurityManager().getSystemSubject()))) {
NodeSet speakers = broker.getStructuralIndex().findElementsByTagName(ElementValue.ELEMENT, docs, test.getName(), null);
Sequence largeSet = executeQuery(broker, "//SPEECH/LINE[fn:contains(., 'love')]/ancestor::SPEECH/LINE[1]", 187, null);
NodeSet result = ((AbstractNodeSet) speakers).selectPrecedingSiblings(largeSet.toNodeSet(), -1);
assertEquals(187, result.getLength());
}
}
use of org.exist.xquery.NameTest in project exist by eXist-db.
the class BasicNodeSetTest method extArrayNodeSet_selectParentChild_4.
@Test
public void extArrayNodeSet_selectParentChild_4() throws XPathException, SAXException, PermissionDeniedException, EXistException {
try (final DBBroker broker = existEmbeddedServer.getBrokerPool().get(Optional.of(existEmbeddedServer.getBrokerPool().getSecurityManager().getSystemSubject()))) {
Sequence nestedSet = executeQuery(broker, "//para[@n = ('1.1.2.1')]", 1, null);
NameTest test = new NameTest(Type.ELEMENT, new QName("section", ""));
NodeSet sections = broker.getStructuralIndex().findElementsByTagName(ElementValue.ELEMENT, docs, test.getName(), null);
NodeSet result = ((NodeSet) nestedSet).selectParentChild(sections.toNodeSet(), NodeSet.DESCENDANT);
assertEquals(1, result.getLength());
}
}
Aggregations