@Test public void selectParentChild_2() throws XPathException, SAXException, PermissionDeniedException { NameTest test = new NameTest(Type.ELEMENT, new QName("SPEAKER", "")); 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()); }
@Test public void selectParentChild() throws XPathException, SAXException, PermissionDeniedException { NameTest test = new NameTest(Type.ELEMENT, new QName("SPEAKER", "")); NodeSet speakers = broker .getStructuralIndex() .findElementsByTagName(ElementValue.ELEMENT, docs, test.getName(), null); Sequence smallSet = executeQuery( broker, "//SPEECH/LINE[fn:contains(., 'perturbed spirit')]/ancestor::SPEECH", 1, null); NodeSet result = NodeSetHelper.selectParentChild(speakers, smallSet.toNodeSet(), NodeSet.DESCENDANT, -1); assertEquals(1, result.getLength()); String value = serialize(broker, result.itemAt(0)); assertEquals(value, "<SPEAKER>HAMLET</SPEAKER>"); }
public NodeSet selectFollowingSiblings(NodeSet siblings, int contextId) { return NodeSetHelper.selectFollowingSiblings(this, siblings, contextId); }
public NodeSet directSelectAttribute( DBBroker broker, org.exist.xquery.NodeTest qname, int contextId) { return NodeSetHelper.directSelectAttributes(broker, this, qname, contextId); }
public NodeSet selectPreceding(NodeSet pl, int contextId) throws XPathException { return NodeSetHelper.selectPreceding(pl, this); }
public NodeSet selectFollowing(NodeSet fl, int contextId) throws XPathException { return NodeSetHelper.selectFollowing(fl, this); }
/** * For a given set of potential ancestor nodes, return all ancestors having descendants in this * node set. * * @param descendants node set containing potential ancestors * @param includeSelf if true, check if the ancestor node itself is contained in this node set * (ancestor-or-self axis) * @param contextId */ public NodeSet selectAncestors(NodeSet descendants, boolean includeSelf, int contextId) { return NodeSetHelper.selectAncestors(this, descendants, includeSelf, contextId); }
/** * Check if any descendant nodes are found within this node set for a given set of potential * ancestor nodes. * * <p>If mode is {@link #DESCENDANT}, the returned node set will contain all descendant nodes * found in this node set for each ancestor. If mode is {@link #ANCESTOR}, the returned set will * contain those ancestor nodes, for which descendants have been found. * * @param al a node set containing potential parent nodes * @param mode selection mode * @param includeSelf if true, check if the ancestor node itself is contained in the set of * descendant nodes (descendant-or-self axis) * @param contextId used to track context nodes when evaluating predicate expressions. If * contextId != {@link Expression#NO_CONTEXT_ID}, the current context will be added to each * result of the selection. */ public NodeSet selectAncestorDescendant( NodeSet al, int mode, boolean includeSelf, int contextId, boolean copyMatches) { return NodeSetHelper.selectAncestorDescendant(this, al, mode, includeSelf, contextId); }
/** * Check if any child nodes are found within this node set for a given set of potential ancestor * nodes. * * <p>If mode is {@link #DESCENDANT}, the returned node set will contain all child nodes found in * this node set for each parent node. If mode is {@link #ANCESTOR}, the returned set will contain * those parent nodes, for which children have been found. * * @param al a node set containing potential parent nodes * @param mode selection mode * @param contextId used to track context nodes when evaluating predicate expressions. If * contextId != {@link Expression#NO_CONTEXT_ID}, the current context will be added to each * result of the of the selection. */ public NodeSet selectParentChild(NodeSet al, int mode, int contextId) { return NodeSetHelper.selectParentChild(this, al, mode, contextId); }