Package org.xmldb.api.modules

Examples of org.xmldb.api.modules.XMLResource


        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();

        // add source node information to the compared xml as it's added by
        // the query processor.
        XMLAssert.assertXMLEqual("<first xmlns:src='http://xml.apache.org/xindice/Query' src:col='/db/testing/current' src:key='doc3' xmlns='http://example.net/person'>Sally</first>",
                                 TextWriter.toString(node));
View Full Code Here


        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.
        assertEquals("doc3", resource.getDocumentId());

        // add source node information to the compared xml as it's added by
        // the query processor. Note, this should work using without the
        // prefixes in the control document using the default namespace,
        // (i.e. xmlns='http://example.net/person') but I couldn't get it to work
View Full Code Here

    }

    public void testInsertDocumentAsDOM() throws Exception {
        Collection col = this.client.getCollection(TEST_COLLECTION_PATH);

        XMLResource document = (XMLResource) col.createResource("testdoc", "XMLResource");
        document.setContentAsDOM(DOMParser.toDocument(CONTENT));
        col.storeResource(document);
        assertEquals(1, this.client.countDocument(TEST_COLLECTION_PATH));

        String content = this.client.getDocument(TEST_COLLECTION_PATH, "testdoc");
        assertXMLEqual(CONTENT, content);
View Full Code Here

                             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);
                    String anActual = TextWriter.toString(aNode);
View Full Code Here

        Collection col = DatabaseManager.getCollection(driver + "/" + path);
        if (col == null) {
            throw new XindiceException("DatabaseManager.getCollection(" + driver + "/" + path + ") returned null");
        }

        XMLResource document = (XMLResource) col.createResource(name, "XMLResource");
        document.setContent(doc);
        col.storeResource(document);
    }
View Full Code Here

    public String getDocument(String path, String name) throws Exception {
        Collection col = DatabaseManager.getCollection(driver + "/" + path);
        if (col == null) {
            throw new XindiceException("DatabaseManager.getCollection(" + driver + "/" + path + ") returned null");
        }
        XMLResource document = (XMLResource) col.getResource(name);

        if (document == null) {
            return null;
        }

        return document.getContent().toString();
    }
View Full Code Here

    public void updateDocument(String path, String name, String doc) throws Exception {
        Collection col = DatabaseManager.getCollection(driver + "/" + path);
        if (col == null) {
            throw new XindiceException("DatabaseManager.getCollection(" + driver + "/" + path + ") returned null");
        }
        XMLResource document = (XMLResource) col.getResource(name);
        document.setContent(doc);
        col.storeResource(document);
    }
View Full Code Here

    public void getDocumentAsSax(String path, String name, ContentHandler handler) throws Exception {
        Collection col = DatabaseManager.getCollection(driver + "/" + path);
        if (col == null) {
            throw new XindiceException("DatabaseManager.getCollection(" + driver + "/" + path + ") returned null");
        }
        XMLResource document = (XMLResource) col.getResource(name);

        if (document == null) {
            return;
        }

        document.getContentAsSAX(handler);
    }
View Full Code Here

    public void removeDocument(String path, String name) throws Exception {
        Collection col = DatabaseManager.getCollection(driver + "/" + path);
        if (col == null) {
            throw new XindiceException("DatabaseManager.getCollection(" + driver + "/" + path + ") returned null");
        }
        XMLResource document = (XMLResource) col.getResource(name);

        col.removeResource(document);
    }
View Full Code Here

            BufferedReader in = new BufferedReader(new FileReader(xmlFileName));
            InputSource source = new InputSource(in);
            DOMParser parser = new DOMParser();
            parser.parse(source);
            String xmlString = toString(parser.getDocument()).trim();
            XMLResource res = insertStringDocument(id, super.toString(document));

            String result = retrieveTextDocument(id).trim();

            super.assertNotNull("LevelZeroTest.testString() - result", result);
            super.assertEquals("LevelZeroTest.testString() - length", xmlString.length(), result.length());
View Full Code Here

TOP

Related Classes of org.xmldb.api.modules.XMLResource

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.