Examples of XUpdateQueryService


Examples of org.xmldb.api.modules.XUpdateQueryService

        assertNotNull(res);
        System.out.println(res.getContent());
    }
   
    private void removeTags() throws Exception {
        XUpdateQueryService service = (XUpdateQueryService)
            testCol.getService("XUpdateQueryService", "1.0");
        int start = rand.nextInt(RUNS / 4);
        for (int i = start; i < RUNS; i++) {
            String xupdate = "<xupdate:modifications version=\"1.0\" xmlns:xupdate=\"http://www.xmldb.org/xupdate\">" +
            "<xupdate:remove select=\"//" + tags[i] + "\"/>" +
            "</xupdate:modifications>";
           
            @SuppressWarnings("unused")
      long mods = service.updateResource("test.xml", xupdate);
            System.out.println("Removed: " + tags[i]);
           
            i += rand.nextInt(3);
        }
    }
View Full Code Here

Examples of org.xmldb.api.modules.XUpdateQueryService

    col.removeResource(document);
    System.out.println("document removed.");
  }

  private Document updateDocument(String updateFile) throws Exception {
    XUpdateQueryService service =
      (XUpdateQueryService) col.getService("XUpdateQueryService", "1.0");

    // Read XUpdate-Modifcations
    System.out.println("update file: " + updateFile);
    File file = new File(updateFile);
    BufferedReader br = new BufferedReader(new FileReader(file));
    char[] characters = new char[new Long(file.length()).intValue()];
    br.read(characters, 0, Long.valueOf(file.length()).intValue());
    br.close();
    String xUpdateModifications = new String(characters);
    System.out.println("modifications: " + xUpdateModifications);
    //

    service.update(xUpdateModifications);

    //col.setProperty("pretty", "true");
    //col.setProperty("encoding", "UTF-8");
    XMLResource ret = (XMLResource) col.getResource(XUPDATE_FILE);
    String xmlString = ((String) ret.getContent());
View Full Code Here

Examples of org.xmldb.api.modules.XUpdateQueryService

    public void execute(Connection connection) throws XMLDBException, EXistException {
        Collection collection = connection.getCollection(collectionPath);
        if (collection == null)
            throw new EXistException("collection " + collectionPath + " not found");
        XUpdateQueryService service = (XUpdateQueryService) collection.getService("XUpdateQueryService", "1.0");

        if (resource == null) {
            modifications = (int) service.update(xupdate);
        } else {
            modifications = (int) service.updateResource(resource, xupdate);
        }
    }
View Full Code Here

Examples of org.xmldb.api.modules.XUpdateQueryService

      System.out.println(i.nextResource().getContent());
    }
  }

  private static void doXUpdate(Collection collection, String xupdate) throws XMLDBException {
    XUpdateQueryService service = (XUpdateQueryService)
      collection.getService("XUpdateQueryService", "1.0");
    long mods = service.update(xupdate);
    System.out.println(mods + " modifications processed.");
  }
View Full Code Here

Examples of org.xmldb.api.modules.XUpdateQueryService

    }
    final String xupdate = writer.toString();

    long modifications = 0;
    try {
      final XUpdateQueryService service = (XUpdateQueryService)c.getService("XUpdateQueryService", "1.0");
      logger.debug("Processing XUpdate request: " + xupdate);
      modifications = service.update(xupdate);
    } catch(final XMLDBException e) {
      throw new XPathException(this, "Exception while processing xupdate: " + e.getMessage(), e);
    }
   
    context.getRootExpression().resetState(false);
View Full Code Here

Examples of org.xmldb.api.modules.XUpdateQueryService

      "  <xu:append select=\"doc('" + getLogPath() + "')/xlog\">\n" +
      content +
      "  </xu:append>\n" +
      "</xu:modifications>";
        log("XUpdate:\n" + xupdate);
    XUpdateQueryService service = (XUpdateQueryService)
    collection.getService("XUpdateQueryService", "1.0");
    service.update(xupdate);
  }
View Full Code Here

Examples of org.xmldb.api.modules.XUpdateQueryService

                    "<xu:modifications xmlns:xu=\"http://www.xmldb.org/xupdate\" version=\"1.0\">" +
                    "   <xu:remove select=\"/items/item[itemno=" + i + "]\"/>" +
                    "</xu:modifications>";

                XPathQueryService query = (XPathQueryService) testCollection.getService("XPathQueryService", "1.0");
                XUpdateQueryService update = (XUpdateQueryService) testCollection.getService("XUpdateQueryService", "1.0");
                long mods = update.updateResource("items.xml", append);
                assertEquals(mods, 1);
                queryResource(query, "items.xml", "//item[price = 55.50]", 1);
                queryResource(query, "items.xml", "//item[@id = 'i" + i + "']",1);
                mods = update.updateResource("items.xml", remove);
                assertEquals(mods, 1);
                queryResource(query, "items.xml", "//item[itemno = " + i + "]", 0);
            }
        } catch (XMLDBException e) {
            e.printStackTrace();
View Full Code Here

Examples of org.xmldb.api.modules.XUpdateQueryService

                    "<xu:modifications xmlns:xu=\"http://www.xmldb.org/xupdate\" version=\"1.0\">" +
                    "   <xu:remove select=\"/items/item[itemno=" + i + "]\"/>" +
                    "</xu:modifications>";

                XPathQueryService query = (XPathQueryService) testCollection.getService("XPathQueryService", "1.0");
                XUpdateQueryService update = (XUpdateQueryService) testCollection.getService("XUpdateQueryService", "1.0");
                long mods = update.updateResource("items.xml", append);
                assertEquals(mods, 1);
                queryResource(query, "items.xml", "//((#exist:optimize#) { item[price = 55.50] })", 1);
                queryResource(query, "items.xml", "//((#exist:optimize#) { item[@id = 'i" + i + "']})",1);
                queryResource(query, "items.xml", "//((#exist:optimize#) { item[itemno = " + i + "] })", 1);
                mods = update.updateResource("items.xml", remove);
                assertEquals(mods, 1);
                queryResource(query, "items.xml", "//((#exist:optimize#) { item[itemno = " + i + "] })", 0);
            }
        } catch (XMLDBException e) {
            e.printStackTrace();
View Full Code Here

Examples of org.xmldb.api.modules.XUpdateQueryService

                                getLogger().debug(message, e);
                            }
                        }
                    } else if ("update".equals(operation)) {
                        try {
                            XUpdateQueryService service =
                                    (XUpdateQueryService) collection.getService("XUpdateQueryService", "1.0");
                            long count = (this.key == null)?
                                    service.update(document) : service.updateResource(this.key, document);
                            message = count + " entries updated.";
                            result = "success";
                        } catch (XMLDBException e) {
                            message = "Failed to update resource " + key + ": " + e.errorCode;
                            getLogger().debug(message, e);
View Full Code Here

Examples of org.xmldb.api.modules.XUpdateQueryService

                        message = "Failed to delete resource " + key + ": " + e.errorCode;
                        getLogger().debug(message, e);
                    }
                } else if("update".equals(operation)) {
                    try {
                        XUpdateQueryService service =
                                (XUpdateQueryService) collection.getService("XUpdateQueryService", "1.0");
                        long count = (this.key == null)?
                                service.update(document) : service.updateResource(this.key, document);
                        message = count + " entries updated.";
                        result = "success";
                    } catch (XMLDBException e) {
                        message = "Failed to update resource " + key + ": " + e.errorCode;
                        getLogger().debug(message, e);
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.