Package org.xmldb.api.base

Examples of org.xmldb.api.base.Collection.storeResource()


          Document doc = db.newDocument();
          Element rootElem = doc.createElement("element");
          doc.appendChild(rootElem);

          resource.setContentAsDOM(doc);
          coll.storeResource(resource);

          coll =
            DatabaseManager.getCollection(
              baseURI,
              username,
View Full Code Here


      propertyElem.appendChild(doc.createTextNode("text"));
      rootElem.appendChild(propertyElem);
      doc.appendChild(rootElem);
      resource.setContentAsDOM(doc);

      coll.storeResource(resource);
      coll.close();

      coll = DatabaseManager.getCollection(baseURI, username, password);
      resource = (XMLResource) coll.getResource(name);
      String s = (String) resource.getContent();
View Full Code Here

      propertyElem.appendChild(doc.createTextNode("text"));
      rootElem.appendChild(propertyElem);
      doc.appendChild(rootElem);
      resource.setContentAsDOM(doc);

      coll.storeResource(resource);
      coll.close();

      coll = DatabaseManager.getCollection(baseURI, username, password);
      resource = (XMLResource) coll.getResource(name);
View Full Code Here

        saxFactory.setValidating(false);
        SAXParser sax = saxFactory.newSAXParser();
        XMLReader reader = sax.getXMLReader();
        reader.setContentHandler(handler);
        reader.parse(new InputSource(new StringReader(xml)));
        testCollection.storeResource(doc);
    }

    @Test
    public void setContentAsDOM() throws XMLDBException, ParserConfigurationException, SAXException, IOException {
        Collection testCollection = DatabaseManager.getCollection(ROOT_URI + "/" + TEST_COLLECTION);
View Full Code Here

                        + "</test>";
        DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = docFactory.newDocumentBuilder();
        Document dom = builder.parse(new InputSource(new StringReader(xml)));
        doc.setContentAsDOM(dom.getDocumentElement());
        testCollection.storeResource(doc);
    }
   
    @Test
    public void setContentAsSource_Reader() throws XMLDBException, SAXException, IOException, XpathException {
        Collection testCollection = DatabaseManager.getCollection(ROOT_URI + "/" + TEST_COLLECTION);
View Full Code Here

                        + "<para>Paragraph4</para>"
                        + "</test>";
       
       
        doc.setContent(new InputSource(new StringReader(xml)));
        testCollection.storeResource(doc);
       
        XMLResource newDoc = (XMLResource)testCollection.getResource("source.xml");
        String newDocXml = (String)newDoc.getContent();
       
        assertXpathEvaluatesTo("Title1", "/test/title/text()", newDocXml);
View Full Code Here

        String resourceName = "QueryTestPerson.xml";
        String id = "test." + System.currentTimeMillis();
        String content = "<?xml version='1.0'?><person id=\"" + id + "\"><name>Jason</name></person>";
        resource = testCollection.createResource(resourceName, "XMLResource");
        resource.setContent(content);
        testCollection.storeResource(resource);

        XPathQueryService service = (XPathQueryService) testCollection.getService("XPathQueryService", "1.0");
        ResourceSet rs = service.query("/person[@id='" + id + "']");

        for (ResourceIterator iterator = rs.getIterator(); iterator.hasMoreResources();) {
View Full Code Here

        try {
            collection = DatabaseManager.getCollection(ROOT_URI + "/" + TEST_COLLECTION);
            result = (XMLResource) collection.createResource(id, XMLResource.RESOURCE_TYPE);
            result.setContent(content);
            collection.storeResource(result);
        } finally {
            closeCollection(collection);
        }
        return result;
    }
View Full Code Here

        Collection testCollectionAsGuest = DatabaseManager.getCollection(ROOT_URI + "/" + TEST_COLLECTION);
        File files[] = getShakespeareSamplesDirectory().listFiles(new XMLFilenameFilter());
        for(File file : files) {
            XMLResource res = (XMLResource) testCollectionAsGuest.createResource(file.getName(), "XMLResource");
            res.setContent(file);
            testCollectionAsGuest.storeResource(res);
        }
    }

    @After
    public void tearDown() throws XMLDBException {
View Full Code Here

            doc.setContent("module namespace a = \"http://www.a.com\"; "
                            +"declare function a:selectionList() as element(ul) { "
                            +"<ul class=\"a\"/> "
                            +"};");
            ((EXistResource) doc).setMimeType("application/xquery");
            testCollection.storeResource(doc);

            String query =
                    "declare option exist:serialize 'indent=no';"
                    +"import module namespace a = \"http://www.a.com\" at \"xmldb:exist://db/test/a.xqy\"; "
                    +"<html xmlns=\"http://www.w3.org/1999/xhtml\"> "
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.