コード例 #1
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>");
  }