Package org.exist.xquery

Examples of org.exist.xquery.NameTest


    private static DocumentSet docs = null;
   
    @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());
    }
View Full Code Here


    }
   
    @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());
    }
View Full Code Here

    }
   
    @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());
    }
View Full Code Here

   
    @Test
    public void ancestorSelector_self() throws XPathException {
        NodeSet ns = seqSpeech.toNodeSet();
        NodeSelector selector = new AncestorSelector(ns, -1, true, true);
        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());
    }
View Full Code Here

    }

    @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());
    }
View Full Code Here

    }
 
    @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));
View Full Code Here

        assertEquals(value, "<SPEAKER>HAMLET</SPEAKER>");
    }
   
    @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());
    }
View Full Code Here

        assertEquals(187, result.getLength());
    }
   
    @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());
    }
View Full Code Here

        assertEquals(51, result.getLength());
    }
   
    @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());
    }
View Full Code Here

        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());
    }
View Full Code Here

TOP

Related Classes of org.exist.xquery.NameTest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.