Package org.xmldb.api.base

Examples of org.xmldb.api.base.ResourceSet


    }

    public void testFetchMultipleCommentNodes() throws Exception {
        String query = "//person/comment()";

        ResourceSet resultSet = xpathservice.query(query);
        assertEquals(2, resultSet.getSize());

        Node result0 = ((XMLResource) resultSet.getResource(0)).getContentAsDOM();
        Node result1 = ((XMLResource) resultSet.getResource(1)).getContentAsDOM();
        assertEquals(" John Smith ", result0.getChildNodes().item(0).getChildNodes().item(0).getNodeValue());
        assertEquals(" Sally Smith ", result1.getChildNodes().item(0).getChildNodes().item(0).getNodeValue());
    }
View Full Code Here


    }

    public void testFetchBoolean() throws Exception {
        String query = "boolean(//person)";

        ResourceSet resultSet = xpathservice.query(query);
        assertEquals(2L, resultSet.getSize());

        Node result0 = ((XMLResource) resultSet.getResource(0)).getContentAsDOM();
        Node result1 = ((XMLResource) resultSet.getResource(1)).getContentAsDOM();
        assertEquals("true", result0.getChildNodes().item(0).getChildNodes().item(0).getNodeValue());
        assertEquals("true", result1.getChildNodes().item(0).getChildNodes().item(0).getNodeValue());
    }
View Full Code Here

    }

    public void testFetchString() throws Exception {
        String query = "string(//person[first='John' and last='Smith']/first)";

        ResourceSet resultSet = xpathservice.query(query);
        assertEquals(2L, resultSet.getSize());

        Node result0 = ((XMLResource) resultSet.getResource(0)).getContentAsDOM();
        Node result1 = ((XMLResource) resultSet.getResource(1)).getContentAsDOM();
        assertEquals("John", result0.getChildNodes().item(0).getChildNodes().item(0).getNodeValue());
        assertEquals(0, result1.getChildNodes().item(0).getChildNodes().getLength());
    }
View Full Code Here

    }

    public void testFetchNumber() throws Exception {
        String query = "count(//person[first='John' and last='Smith'])";

        ResourceSet resultSet = xpathservice.query(query);
        assertEquals(2L, resultSet.getSize());

        Node result0 = ((XMLResource) resultSet.getResource(0)).getContentAsDOM();
        Node result1 = ((XMLResource) resultSet.getResource(1)).getContentAsDOM();
        assertEquals("1.0", result0.getChildNodes().item(0).getChildNodes().item(0).getNodeValue());
        assertEquals("0.0", result1.getChildNodes().item(0).getChildNodes().item(0).getNodeValue());
    }
View Full Code Here

    }

    public void testSrcAddedToRootOnly() throws Exception {
        String query = "//person[first='John' and last='Smith']";

        ResourceSet resultSet = xpathservice.query(query);
        assertEquals(1, resultSet.getSize());

        XMLResource resource = (XMLResource) resultSet.getResource(0);

        String john
                = "<?xml version=\"1.0\"?>"
                + "<person xmlns:src='http://xml.apache.org/xindice/Query' src:col='/db/testing/current' src:key='doc1'>"
                +   "<!-- John Smith -->"
View Full Code Here

        String query = "//h:person[h:first='Sally' and h:last='Smith']/h:first";

        xpathservice.setNamespace("h", "http://example.net/person");

        ResourceSet resultSet = xpathservice.query(query);
        assertEquals(1, resultSet.getSize());

        XMLResource resource = (XMLResource) resultSet.getResource(0);

        // ensure that the resource has the correct doc id.
        assertEquals("doc3", resource.getDocumentId());

        Node node = resource.getContentAsDOM();
View Full Code Here

        String query = "//h:person[h:first='Sally' and h:last='Smith']";

        xpathservice.setNamespace("h", "http://example.net/person");

        ResourceSet resultSet = xpathservice.query(query);
        assertEquals(1, resultSet.getSize());

        XMLResource resource = (XMLResource) resultSet.getResource(0);
        Node node = resource.getContentAsDOM();
        String retrieved = TextWriter.toString(node);
        assertFalse("Namespace definitions imported deep in: " + retrieved, -1 == retrieved.indexOf("<p:first>"));

        // ensure that the resource has the correct doc id.
View Full Code Here

                +   "<phone call=\"no\" type=\"work\">555-345-6789</phone>"
                + "</person>";
        this.client.insertDocument(TEST_COLLECTION_PATH, "doc3", document3);

        try {
            ResourceSet resultSet = xpathservice.query(query);
            assertEquals(1, resultSet.getSize());
        } finally {
            this.client.removeDocument(TEST_COLLECTION_PATH, "doc3");
        }
    }
View Full Code Here

        public Result runQuery() throws Exception {
            Collection col = IndexedSearchTest.this.client.getCollection(IndexedSearchTest.COLLECTION_PATH);
            XPathQueryService xpathservice = (XPathQueryService) col.getService("XPathQueryService", "1.0");

            org.apache.xindice.Stopwatch aStopwatch = new org.apache.xindice.Stopwatch("Non-indexed starts-with query", true);
            ResourceSet resultSet = xpathservice.query(itsTestQuery);
            aStopwatch.stop();
            return new Result(resultSet, aStopwatch.elapsed());
        }
View Full Code Here

         *
         * @param theResult Result to check
         */
        public void checkResult(Result theResult) throws Exception {
            assertNotNull("Parameter theResult is null", theResult);
            ResourceSet aResourceSet = theResult.getResourceSet();
            assertNotNull("theResult contains a null ResourceSet", aResourceSet);
            if (itsExpectedResourceCount >= 0) {
                assertEquals("Result did not contain expected number of resources",
                             itsExpectedResourceCount, aResourceSet.getSize());
            }

            if (itsExpectedResources != null && itsExpectedResources.length > 1) {
                for (int anIndex = 0; anIndex < itsExpectedResources.length / 2; anIndex += 2) {
                    XMLResource aResource = (XMLResource) aResourceSet.getResource(anIndex);
                    Node aNode = aResource.getContentAsDOM();
                    int anExpectedSourceDocumentIndex = ((Integer) itsExpectedResources[anIndex]).intValue();
                    String anExpected = "<?xml version=\"1.0\"?>\n" + addSource((String) itsExpectedResources[anIndex + 1],
                                                                                TEST_DOCUMENT_PREFIX + anIndex,
                                                                                IndexedSearchTest.COLLECTION_PATH);
View Full Code Here

TOP

Related Classes of org.xmldb.api.base.ResourceSet

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.