use of org.exist.xquery.NameTest in project exist by eXist-db.
the class BasicNodeSetTest method extArrayNodeSet_selectParentChild_1.
@Test
public void extArrayNodeSet_selectParentChild_1() throws XPathException, SAXException, PermissionDeniedException, EXistException {
try (final DBBroker broker = existEmbeddedServer.getBrokerPool().get(Optional.of(existEmbeddedServer.getBrokerPool().getSecurityManager().getSystemSubject()))) {
Sequence nestedSet = executeQuery(broker, "//section[@n = ('1.1', '1.1.1')]", 2, null);
NameTest test = new NameTest(Type.ELEMENT, new QName("para", ""));
NodeSet children = broker.getStructuralIndex().findElementsByTagName(ElementValue.ELEMENT, docs, test.getName(), null);
NodeSet result = children.selectParentChild(nestedSet.toNodeSet(), NodeSet.DESCENDANT);
assertEquals(3, result.getLength());
}
}
use of org.exist.xquery.NameTest 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());
}
}
use of org.exist.xquery.NameTest 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());
}
}
use of org.exist.xquery.NameTest in project exist by eXist-db.
the class BasicNodeSetTest method selectAncestors.
@Test
public void selectAncestors() throws XPathException, SAXException, PermissionDeniedException, EXistException {
NameTest test = new NameTest(Type.ELEMENT, new QName("SCENE", ""));
try (final DBBroker broker = existEmbeddedServer.getBrokerPool().get(Optional.of(existEmbeddedServer.getBrokerPool().getSecurityManager().getSystemSubject()))) {
NodeSet scenes = broker.getStructuralIndex().findElementsByTagName(ElementValue.ELEMENT, docs, test.getName(), null);
Sequence largeSet = executeQuery(broker, "//SPEECH/LINE[fn:contains(., 'love')]/ancestor::SPEECH", 187, null);
NodeSet result = ((AbstractNodeSet) scenes).selectAncestors(largeSet.toNodeSet(), false, -1);
assertEquals(49, result.getLength());
}
}
use of org.exist.xquery.NameTest in project exist by eXist-db.
the class BasicNodeSetTest method selectAncestorDescendant.
@Test
public void selectAncestorDescendant() 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 outerSet = executeQuery(broker, "//SCENE/TITLE[fn:contains(., 'closet')]/ancestor::SCENE", 1, null);
NodeSet result = speakers.selectAncestorDescendant(outerSet.toNodeSet(), NodeSet.DESCENDANT, false, -1, true);
assertEquals(56, result.getLength());
}
}
Aggregations