예제 #1
0
  @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());
  }
예제 #2
0
  @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>");
  }
예제 #3
0
 public NodeSet selectFollowingSiblings(NodeSet siblings, int contextId) {
   return NodeSetHelper.selectFollowingSiblings(this, siblings, contextId);
 }
예제 #4
0
 public NodeSet directSelectAttribute(
     DBBroker broker, org.exist.xquery.NodeTest qname, int contextId) {
   return NodeSetHelper.directSelectAttributes(broker, this, qname, contextId);
 }
예제 #5
0
 public NodeSet selectPreceding(NodeSet pl, int contextId) throws XPathException {
   return NodeSetHelper.selectPreceding(pl, this);
 }
예제 #6
0
 public NodeSet selectFollowing(NodeSet fl, int contextId) throws XPathException {
   return NodeSetHelper.selectFollowing(fl, this);
 }
예제 #7
0
 /**
  * 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);
 }
예제 #8
0
 /**
  * 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);
 }
예제 #9
0
 /**
  * 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);
 }