Package org.xmldb.api.modules

Examples of org.xmldb.api.modules.XMLResource


         // Create xml string from form values
         ourdoc = toXml(fname,lname,workphone,homephone,cellphone,homeemail,workemail,
                           homeaddress,workaddress);
     
         // Get the XMLResource and replace the content
         XMLResource resource = (XMLResource) col.getResource(dockey);
         resource.setContent(ourdoc);
         col.storeResource(resource);
        
      } catch ( Exception e) {
         e.printStackTrace();
View Full Code Here


            ResourceSet resultSet = service.query(querystring);
            results = resultSet.getIterator();

            while (results.hasMoreResources()) {
                XMLResource resource = (XMLResource) results.nextResource();
                String documentstr = (String) resource.getContent();
                System.out.println(documentstr);
            }

        } catch (Exception e) {
            System.out.println("ERROR : " + e.getMessage());
View Full Code Here

            if (files != null) {
                System.out.println("Extracting " + files.length + " files from " +
                                   (String) table.get(XMLTools.COLLECTION));
                for (int j = 0; j < files.length; j++) {
                    // TODO: BinaryResource support
                    XMLResource res =
                            (XMLResource) col.getResource(files[j]);
                    String content = (String) res.getContent();
                    FileOutputStream output =
                            new FileOutputStream(new File(directory, files[j]));

                    /* UTF8FIXED: as we omit encoding declaration in output XML
                     * for the moment, we MUST write file in UTF-8
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

    ResourceIterator results = resultSet.getIterator();
    List res = asList(results);
    assertEquals(1, res.size());

    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>",
View Full Code Here

    ResourceIterator results = resultSet.getIterator();
    List res = asList(results);
    assertEquals(2, res.size());

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

    Node node = resource.getContentAsDOM();

    client.removeDocument(TEST_COLLECTION_PATH, "doc3");
  }
View Full Code Here

    ResourceIterator results = resultSet.getIterator();

    List res = asList(results);
    assertEquals(1, res.size());

    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'>"
        + "<first>John</first>"
        + "<last>Smith</last>"
        + "<age>30</age>"
        + "<phone type=\"work\">555-345-6789</phone>"
        + "</person>";

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

    XMLAssert.assertXMLEqual(john, TextWriter.toString(resource.getContentAsDOM()));
  }
View Full Code Here

    ResourceIterator results = resultSet.getIterator();
    List res = asList(results);
    assertEquals(1, res.size());

    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>",
View Full Code Here

    ResourceIterator results = resultSet.getIterator();
    List res = asList(results);
    assertEquals(1, res.size());

    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

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.