コード例 #1
0
  @Test
  public void getParents() throws XPathException, SAXException, PermissionDeniedException {
    Sequence largeSet =
        executeQuery(broker, "//SPEECH/LINE[fn:contains(., 'love')]/ancestor::SPEECH", 187, null);

    NodeSet result = ((AbstractNodeSet) largeSet).getParents(-1);
    assertEquals(51, result.getLength());
  }
コード例 #2
0
 public NodeSet filterDocuments(NodeSet otherSet) {
   DocumentSet docs = otherSet.getDocumentSet();
   NodeSet newSet = new NewArrayNodeSet();
   for (Iterator i = iterator(); i.hasNext(); ) {
     NodeProxy p = (NodeProxy) i.next();
     if (docs.contains(p.getDocument().getDocId())) newSet.add(p);
   }
   return newSet;
 }
コード例 #3
0
  @Test
  public void selectAncestorDescendant_2()
      throws XPathException, SAXException, PermissionDeniedException {
    Sequence outerSet =
        executeQuery(broker, "//SCENE/TITLE[fn:contains(., 'closet')]/ancestor::SCENE", 1, null);

    NodeSet result =
        ((AbstractNodeSet) outerSet)
            .selectAncestorDescendant(outerSet.toNodeSet(), NodeSet.DESCENDANT, true, -1, true);
    assertEquals(1, result.getLength());
  }
コード例 #4
0
  @Test
  public void ancestorSelector() throws XPathException {
    NodeSelector selector = new AncestorSelector(seqSpeech.toNodeSet(), -1, false, true);
    NameTest test = new NameTest(Type.ELEMENT, new QName("ACT", ""));
    NodeSet set =
        broker
            .getStructuralIndex()
            .findElementsByTagName(
                ElementValue.ELEMENT, seqSpeech.getDocumentSet(), test.getName(), selector);

    assertEquals(15, set.getLength());
  }
コード例 #5
0
  @Test
  public void descendantOrSelfSelector() throws XPathException {
    NodeSelector selector = new DescendantOrSelfSelector(seqSpeech.toNodeSet(), -1);
    NameTest test = new NameTest(Type.ELEMENT, new QName("SPEECH", ""));
    NodeSet set =
        broker
            .getStructuralIndex()
            .findElementsByTagName(
                ElementValue.ELEMENT, seqSpeech.getDocumentSet(), test.getName(), selector);

    assertEquals(2628, set.getLength());
  }
コード例 #6
0
  @Test
  public void childSelector() throws XPathException {
    NodeSelector selector = new ChildSelector(seqSpeech.toNodeSet(), -1);
    NameTest test = new NameTest(Type.ELEMENT, new QName("LINE", ""));
    NodeSet set =
        broker
            .getStructuralIndex()
            .findElementsByTagName(
                ElementValue.ELEMENT, seqSpeech.getDocumentSet(), test.getName(), selector);

    assertEquals(9492, set.getLength());
  }
コード例 #7
0
  @Test
  public void descendantSelector() throws XPathException, SAXException, PermissionDeniedException {
    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());
  }
コード例 #8
0
 /**
  * Return a new node set which represents the union of the current node set and the given node
  * set.
  *
  * @param other
  */
 public NodeSet union(NodeSet other) {
   NewArrayNodeSet result = new NewArrayNodeSet();
   result.addAll(other);
   NodeProxy p, c;
   for (Iterator i = iterator(); i.hasNext(); ) {
     p = (NodeProxy) i.next();
     if (other.contains(p)) {
       c = other.get(p);
       if (c != null) c.addMatches(p);
     } else result.add(p);
   }
   return result;
 }
コード例 #9
0
  @Test
  public void selectAncestors() throws XPathException, SAXException, PermissionDeniedException {
    NameTest test = new NameTest(Type.ELEMENT, new QName("SCENE", ""));
    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());
  }
コード例 #10
0
  @Test
  public void extArrayNodeSet_selectParentChild_3()
      throws XPathException, SAXException, PermissionDeniedException {
    Sequence nestedSet = executeQuery(broker, "//section[@n = ('1.1', '1.1.1', '1.2')]", 3, 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(4, result.getLength());
  }
コード例 #11
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());
  }
コード例 #12
0
  @Test
  public void selectAncestorDescendant()
      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 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());
  }
コード例 #13
0
  /**
   * Return a new node set containing the parent nodes of all nodes in the current set.
   *
   * @param contextId an <code>int</code> value
   * @return a <code>NodeSet</code> value
   */
  public NodeSet getParents(int contextId) {
    NodeSet parents = new NewArrayNodeSet();
    NodeProxy parent = null;
    for (Iterator i = iterator(); i.hasNext(); ) {
      NodeProxy current = (NodeProxy) i.next();
      NodeId parentID = current.getNodeId().getParentId();
      // Filter out the temporary nodes wrapper element
      // Moved the parentID != NodeId.DOCUMENT_NODE test inside for /a/parent::node() to work
      // correctly.
      // Added the needed test parentID != null, detected in org.exist.xquery.OptimizerTest
      // "//node()[parent::mods:title &= 'ethnic']" which caused an NPE here
      // since I dont know when. /ljo
      if (parentID != null
          && !(parentID.getTreeLevel() == 1
              && current.getDocument().getCollection().isTempCollection())) {
        if (parent == null
            || parent.getDocument().getDocId() != current.getDocument().getDocId()
            || !parent.getNodeId().equals(parentID)) {
          if (parentID != NodeId.DOCUMENT_NODE) {
            parent =
                new NodeProxy(
                    current.getDocument(),
                    parentID,
                    Node.ELEMENT_NODE,
                    StoredNode.UNKNOWN_NODE_IMPL_ADDRESS);
          } else {
            parent =
                new NodeProxy(
                    current.getDocument(),
                    parentID,
                    Node.DOCUMENT_NODE,
                    StoredNode.UNKNOWN_NODE_IMPL_ADDRESS);
          }
        }
        if (Expression.NO_CONTEXT_ID != contextId) {
          parent.addContextNode(contextId, current);
        } else {
          parent.copyContext(current);
        }
        parent.addMatches(current);
        parents.add(parent);
      }
    }

    return parents;
  }
コード例 #14
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>");
  }
コード例 #15
0
ファイル: RestoreElement.java プロジェクト: x-clone/Xfolite
  public void handleEvent(DOMEvent evt) {
    String src = this.getAttribute("src");
    String ref = getAttribute("ref");
    String name = getAttribute("name");
    if (src == "" || ref == "" || name == "") {
      logError("Empty src, ref or name attribute");
      return;
    }
    NodeSet nset = this.getValue(ref).asNodeSet();
    Node refNode = null;
    if (nset != null) {
      refNode = nset.firstNode();
    }
    if (refNode == null) {
      logError("Reference binding failed");
    }

    ((XFormsDocument) ownerDocument).restore(src, refNode, name);
  }
コード例 #16
0
  /* (non-Javadoc)
   * @see org.exist.xquery.Expression#eval(org.exist.dom.DocumentSet, org.exist.xquery.value.Sequence, org.exist.xquery.value.Item)
   */
  public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathException {
    logger.error(
        "Use of deprecated function fn:doctype(). "
            + "It will be removed soon. Please "
            + "use util:doctype() instead.");
    if (context.getProfiler().isEnabled()) {
      context.getProfiler().start(this);
      context
          .getProfiler()
          .message(
              this,
              Profiler.DEPENDENCIES,
              "DEPENDENCIES",
              Dependency.getDependenciesName(this.getDependencies()));
      if (contextSequence != null)
        context
            .getProfiler()
            .message(this, Profiler.START_SEQUENCES, "CONTEXT SEQUENCE", contextSequence);
      if (contextItem != null)
        context
            .getProfiler()
            .message(this, Profiler.START_SEQUENCES, "CONTEXT ITEM", contextItem.toSequence());
    }

    MutableDocumentSet docs = new DefaultDocumentSet();
    for (int i = 0; i < getArgumentCount(); i++) {
      Sequence seq = getArgument(i).eval(contextSequence, contextItem);
      for (SequenceIterator j = seq.iterate(); j.hasNext(); ) {
        String next = j.nextItem().getStringValue();
        context.getBroker().getXMLResourcesByDoctype(next, docs);
      }
    }

    NodeSet result = new ExtArrayNodeSet(1);
    for (Iterator i = docs.getDocumentIterator(); i.hasNext(); ) {
      result.add(new NodeProxy((DocumentImpl) i.next(), NodeId.DOCUMENT_NODE));
    }

    if (context.getProfiler().isEnabled()) context.getProfiler().end(this, "", result);

    return result;
  }
コード例 #17
0
 public NodeSet except(NodeSet other) {
   AVLTreeNodeSet r = new AVLTreeNodeSet();
   NodeProxy l;
   for (Iterator i = iterator(); i.hasNext(); ) {
     l = (NodeProxy) i.next();
     if (!other.contains(l)) {
       r.add(l);
     }
   }
   return r;
 }
コード例 #18
0
 public NodeSet deepIntersection(NodeSet other) {
   // ExtArrayNodeSet r = new ExtArrayNodeSet();
   AVLTreeNodeSet r = new AVLTreeNodeSet();
   NodeProxy l, p, q;
   for (Iterator i = iterator(); i.hasNext(); ) {
     l = (NodeProxy) i.next();
     if ((p = other.parentWithChild(l, false, true, NodeProxy.UNKNOWN_NODE_LEVEL)) != null) {
       if (p.getNodeId().equals(l.getNodeId())) p.addMatches(l);
       r.add(p);
     }
   }
   for (Iterator i = other.iterator(); i.hasNext(); ) {
     l = (NodeProxy) i.next();
     if ((q = parentWithChild(l, false, true, NodeProxy.UNKNOWN_NODE_LEVEL)) != null) {
       if ((p = r.get(q)) != null) {
         p.addMatches(l);
       } else r.add(l);
     }
   }
   return r;
 }
コード例 #19
0
  @Test
  public void nodeProxy_getParents()
      throws XPathException, SAXException, PermissionDeniedException {
    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());
  }
コード例 #20
0
 /**
  * Return a new node set, which represents the intersection of the current node set with the given
  * node set.
  *
  * @param other
  */
 public NodeSet intersection(NodeSet other) {
   AVLTreeNodeSet r = new AVLTreeNodeSet();
   NodeProxy l, p;
   for (Iterator i = iterator(); i.hasNext(); ) {
     l = (NodeProxy) i.next();
     if ((p = other.get(l)) != null) {
       l.addMatches(p);
       r.add(l);
     }
   }
   //        for (Iterator i = other.iterator(); i.hasNext();) {
   //            l = (NodeProxy) i.next();
   //            if (contains(l)) {
   //                if ((p = r.get(l)) != null) {
   //                    p.addMatches(l);
   //                } else
   //                    r.add(l);
   //            }
   //        }
   return r;
 }
コード例 #21
0
ファイル: Reasoning.java プロジェクト: adrianomelo/tg
  public static void main(String[] args) {

    try {
      // Create our ontology manager in the usual way.
      OWLOntologyManager manager = OWLManager.createOWLOntologyManager();

      // Load a copy of the people+pets ontology.  We'll load the ontology from the web (it's
      // acutally located
      // in the TONES ontology repository).
      IRI docIRI = IRI.create(DOCUMENT_IRI);
      // We load the ontology from a document - our IRI points to it directly
      OWLOntology ont = manager.loadOntologyFromOntologyDocument(docIRI);
      System.out.println("Loaded " + ont.getOntologyID());

      // We need to create an instance of OWLReasoner.  An OWLReasoner provides the basic
      // query functionality that we need, for example the ability obtain the subclasses
      // of a class etc.  To do this we use a reasoner factory.

      // Create a reasoner factory.  In this case, we will use HermiT, but we could also
      // use FaCT++ (http://code.google.com/p/factplusplus/) or
      // Pellet(http://clarkparsia.com/pellet)
      // Note that (as of 03 Feb 2010) FaCT++ and Pellet OWL API 3.0.0 compatible libraries are
      // expected to be available in the near future).

      // For now, we'll use HermiT
      // HermiT can be downloaded from http://hermit-reasoner.com
      // Make sure you get the HermiT library and add it to your class path.  You can then
      // instantiate the HermiT reasoner factory:
      // Comment out the first line below and uncomment the second line below to instantiate
      // the HermiT reasoner factory.  You'll also need to import the
      // org.semanticweb.HermiT.Reasoner
      // package.
      OWLReasonerFactory reasonerFactory = null;
      //            OWLReasonerFactory reasonerFactory = new Reasoner.ReasonerFactory();

      // We'll now create an instance of an OWLReasoner (the implementation being provided by HermiT
      // as
      // we're using the HermiT reasoner factory).  The are two categories of reasoner, Buffering
      // and
      // NonBuffering.  In our case, we'll create the buffering reasoner, which is the default kind
      // of reasoner.
      // We'll also attach a progress monitor to the reasoner.  To do this we set up a configuration
      // that
      // knows about a progress monitor.

      // Create a console progress monitor.  This will print the reasoner progress out to the
      // console.
      ConsoleProgressMonitor progressMonitor = new ConsoleProgressMonitor();
      // Specify the progress monitor via a configuration.  We could also specify other setup
      // parameters in
      // the configuration, and different reasoners may accept their own defined parameters this
      // way.
      OWLReasonerConfiguration config = new SimpleConfiguration(progressMonitor);
      // Create a reasoner that will reason over our ontology and its imports closure.  Pass in the
      // configuration.
      OWLReasoner reasoner = reasonerFactory.createReasoner(ont, config);

      // Ask the reasoner to do all the necessary work now
      reasoner.precomputeInferences();

      // We can determine if the ontology is actually consistent (in this case, it should be).
      boolean consistent = reasoner.isConsistent();
      System.out.println("Consistent: " + consistent);
      System.out.println("\n");

      // We can easily get a list of unsatisfiable classes.  (A class is unsatisfiable if it
      // can't possibly have any instances).  Note that the getUnsatisfiableClasses method
      // is really just a convenience method for obtaining the classes that are equivalent
      // to owl:Nothing.  In our case there should be just one unsatisfiable class - "mad_cow"
      // We ask the reasoner for the unsatisfiable classes, which returns the bottom node
      // in the class hierarchy (an unsatisfiable class is a subclass of every class).
      Node<OWLClass> bottomNode = reasoner.getUnsatisfiableClasses();
      // This node contains owl:Nothing and all the classes that are equivalent to owl:Nothing -
      // i.e. the unsatisfiable classes.
      // We just want to print out the unsatisfiable classes excluding owl:Nothing, and we can
      // used a convenience method on the node to get these
      Set<OWLClass> unsatisfiable = bottomNode.getEntitiesMinusBottom();
      if (!unsatisfiable.isEmpty()) {
        System.out.println("The following classes are unsatisfiable: ");
        for (OWLClass cls : unsatisfiable) {
          System.out.println("    " + cls);
        }
      } else {
        System.out.println("There are no unsatisfiable classes");
      }
      System.out.println("\n");

      // Now we want to query the reasoner for all descendants of vegetarian.  Vegetarians are
      // defined in the
      // ontology to be animals that don't eat animals or parts of animals.
      OWLDataFactory fac = manager.getOWLDataFactory();
      // Get a reference to the vegetarian class so that we can as the reasoner about it.
      // The full IRI of this class happens to be:
      // <http://owl.man.ac.uk/2005/07/sssw/people#vegetarian>
      OWLClass vegPizza =
          fac.getOWLClass(IRI.create("http://owl.man.ac.uk/2005/07/sssw/people#vegetarian"));

      // Now use the reasoner to obtain the subclasses of vegetarian.
      // We can ask for the direct subclasses of vegetarian or all of the (proper) subclasses of
      // vegetarian.
      // In this case we just want the direct ones (which we specify by the "true" flag).
      NodeSet<OWLClass> subClses = reasoner.getSubClasses(vegPizza, true);

      // The reasoner returns a NodeSet, which represents a set of Nodes.
      // Each node in the set represents a subclass of vegetarian pizza.  A node of classes contains
      // classes,
      // where each class in the node is equivalent. For example, if we asked for the
      // subclasses of some class A and got back a NodeSet containing two nodes {B, C} and {D}, then
      // A would have
      // two proper subclasses.  One of these subclasses would be equivalent to the class D, and the
      // other would
      // be the class that is equivalent to class B and class C.

      // In this case, we don't particularly care about the equivalences, so we will flatten this
      // set of sets and print the result
      Set<OWLClass> clses = subClses.getFlattened();
      System.out.println("Subclasses of vegetarian: ");
      for (OWLClass cls : clses) {
        System.out.println("    " + cls);
      }
      System.out.println("\n");

      // In this case, we should find that the classes, cow, sheep and giraffe are vegetarian.  Note
      // that in this
      // ontology only the class cow had been stated to be a subclass of vegetarian.  The fact that
      // sheep and
      // giraffe are subclasses of vegetarian was implicit in the ontology (through other things we
      // had said)
      // and this illustrates why it is important to use a reasoner for querying an ontology.

      // We can easily retrieve the instances of a class.  In this example we'll obtain the
      // instances of
      // the class pet.  This class has a full IRI of <http://owl.man.ac.uk/2005/07/sssw/people#pet>

      // We need to obtain a reference to this class so that we can ask the reasoner about it.
      OWLClass country =
          fac.getOWLClass(IRI.create("http://owl.man.ac.uk/2005/07/sssw/people#pet"));
      // Ask the reasoner for the instances of pet
      NodeSet<OWLNamedIndividual> individualsNodeSet = reasoner.getInstances(country, true);
      // The reasoner returns a NodeSet again.  This time the NodeSet contains individuals.
      // Again, we just want the individuals, so get a flattened set.
      Set<OWLNamedIndividual> individuals = individualsNodeSet.getFlattened();
      System.out.println("Instances of pet: ");
      for (OWLNamedIndividual ind : individuals) {
        System.out.println("    " + ind);
      }
      System.out.println("\n");

      // Again, it's worth noting that not all of the individuals that are returned were explicitly
      // stated
      // to be pets.

      // Finally, we can ask for the property values (property assertions in OWL speak) for a given
      // individual
      // and property.
      // Let's get the property values for the individual Mick, the full IRI of which is
      // <http://owl.man.ac.uk/2005/07/sssw/people#Mick>

      // Get a reference to the individual Mick
      OWLNamedIndividual mick =
          fac.getOWLNamedIndividual(IRI.create("http://owl.man.ac.uk/2005/07/sssw/people#Mick"));

      // Let's get the pets of Mick
      // Get hold of the has_pet property which has a full IRI of
      // <http://owl.man.ac.uk/2005/07/sssw/people#has_pet>
      OWLObjectProperty hasPet =
          fac.getOWLObjectProperty(IRI.create("http://owl.man.ac.uk/2005/07/sssw/people#has_pet"));

      // Now ask the reasoner for the has_pet property values for Mick
      NodeSet<OWLNamedIndividual> petValuesNodeSet = reasoner.getObjectPropertyValues(mick, hasPet);
      Set<OWLNamedIndividual> values = petValuesNodeSet.getFlattened();
      System.out.println("The has_pet property values for Mick are: ");
      for (OWLNamedIndividual ind : values) {
        System.out.println("    " + ind);
      }

      // Notice that Mick has a pet Rex, which wasn't asserted in the ontology.

      // Finally, let's print out the class hierarchy.
      // Get hold of the top node in the class hierarchy (containing owl:Thing)
      // Now print the hierarchy out
      Node<OWLClass> topNode = reasoner.getTopClassNode();
      print(topNode, reasoner, 0);

    } catch (UnsupportedOperationException exception) {
      System.out.println("Unsupported reasoner operation.");
    } catch (OWLOntologyCreationException e) {
      System.out.println("Could not load the pizza ontology: " + e.getMessage());
    }
  }
コード例 #22
0
  @Test
  public void testOptimizations() throws XPathException, SAXException, PermissionDeniedException {

    Serializer serializer = broker.getSerializer();
    serializer.reset();
    DocumentSet docs = root.allDocs(broker, new DefaultDocumentSet(), true);

    System.out.println("------------ Testing NativeElementIndex.findChildNodesByTagName ---------");
    // parent set: 1.1.1; child set: 1.1.1.1, 1.1.1.2, 1.1.1.3, 1.1.2.1, 1.2.1
    ExtNodeSet nestedSet = (ExtNodeSet) executeQuery(broker, "//section[@n = '1.1.1']", 1, null);
    NodeSet children =
        broker
            .getStructuralIndex()
            .findDescendantsByTagName(
                ElementValue.ELEMENT,
                new QName("para", ""),
                Constants.CHILD_AXIS,
                docs,
                nestedSet,
                -1);
    assertEquals(3, children.getLength());

    // parent set: 1.1; child set: 1.1.1, 1.1.2
    nestedSet = (ExtNodeSet) executeQuery(broker, "//section[@n = '1.1']", 1, null);
    children =
        broker
            .getStructuralIndex()
            .findDescendantsByTagName(
                ElementValue.ELEMENT,
                new QName("section", ""),
                Constants.CHILD_AXIS,
                docs,
                nestedSet,
                -1);
    assertEquals(2, children.getLength());

    // parent set: 1, 1.1, 1.1.1, 1.1.2 ; child set: 1.1.1.1, 1.1.1.2, 1.1.1.3, 1.1.2.1, 1.2.1
    // problem: ancestor set contains nested nodes
    nestedSet =
        (ExtNodeSet) executeQuery(broker, "//section[@n = ('1.1', '1.1.1', '1.1.2')]", 3, null);
    children =
        broker
            .getStructuralIndex()
            .findDescendantsByTagName(
                ElementValue.ELEMENT,
                new QName("para", ""),
                Constants.CHILD_AXIS,
                docs,
                nestedSet,
                -1);
    assertEquals(4, children.getLength());

    // parent set: 1.1, 1.1.2, 1.2 ; child set: 1.1.1.1, 1.1.1.2, 1.1.1.3, 1.1.2.1, 1.2.1
    // problem: ancestor set contains nested nodes
    nestedSet =
        (ExtNodeSet) executeQuery(broker, "//section[@n = ('1.1', '1.1.2', '1.2')]", 3, null);
    children =
        broker
            .getStructuralIndex()
            .findDescendantsByTagName(
                ElementValue.ELEMENT,
                new QName("para", ""),
                Constants.CHILD_AXIS,
                docs,
                nestedSet,
                -1);
    assertEquals(2, children.getLength());

    nestedSet = (ExtNodeSet) executeQuery(broker, "//section[@n = '1.1']", 1, null);
    children =
        broker
            .getStructuralIndex()
            .findDescendantsByTagName(
                ElementValue.ELEMENT,
                new QName("para", ""),
                Constants.DESCENDANT_AXIS,
                docs,
                nestedSet,
                -1);
    assertEquals(4, children.getLength());

    nestedSet = (ExtNodeSet) executeQuery(broker, "//section[@n = '1']", 1, null);
    children =
        broker
            .getStructuralIndex()
            .findDescendantsByTagName(
                ElementValue.ELEMENT,
                new QName("para", ""),
                Constants.DESCENDANT_AXIS,
                docs,
                nestedSet,
                -1);
    assertEquals(5, children.getLength());

    nestedSet = (ExtNodeSet) executeQuery(broker, "//section[@n = '1.1.2']", 1, null);
    children =
        broker
            .getStructuralIndex()
            .findDescendantsByTagName(
                ElementValue.ELEMENT,
                new QName("section", ""),
                Constants.DESCENDANT_SELF_AXIS,
                docs,
                nestedSet,
                -1);
    assertEquals(1, children.getLength());

    nestedSet = (ExtNodeSet) executeQuery(broker, "//section[@n = '1.1.2']", 1, null);
    children =
        broker
            .getStructuralIndex()
            .findDescendantsByTagName(
                ElementValue.ATTRIBUTE,
                new QName("n", ""),
                Constants.ATTRIBUTE_AXIS,
                docs,
                nestedSet,
                -1);
    assertEquals(1, children.getLength());

    nestedSet = (ExtNodeSet) executeQuery(broker, "//section[@n = '1.1']", 1, null);
    children =
        broker
            .getStructuralIndex()
            .findDescendantsByTagName(
                ElementValue.ATTRIBUTE,
                new QName("n", ""),
                Constants.DESCENDANT_ATTRIBUTE_AXIS,
                docs,
                nestedSet,
                -1);
    assertEquals(7, children.getLength());

    System.out.println("------------ PASSED: NativeElementIndex.findChildNodesByTagName ---------");
  }