Exemplo n.º 1
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());
  }
Exemplo n.º 2
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());
  }
Exemplo n.º 3
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());
  }
Exemplo n.º 4
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());
  }
Exemplo n.º 5
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());
  }
Exemplo n.º 6
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());
  }
Exemplo n.º 7
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());
  }
Exemplo n.º 8
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());
  }
Exemplo n.º 9
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>");
  }
Exemplo n.º 10
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());
  }