Package org.xmldb.api.modules

Examples of org.xmldb.api.modules.XQueryService


        return result;
    }

    /** For queries without associated data */
    private XQueryService getQueryService() throws XMLDBException {
        final XQueryService service = (XQueryService) testCollection.getService(
            "XPathQueryService", "1.0");
        return service;
    }
View Full Code Here


        final XMLResource doc =
            (XMLResource) testCollection.createResource(
                documentName, "XMLResource" );
        doc.setContent(content);
        testCollection.storeResource(doc);
        final XQueryService service =
            (XQueryService) testCollection.getService(
                "XPathQueryService",
                "1.0");
        return service;
    }
View Full Code Here

    @Test (expected=XMLDBException.class)
    public void manualRelease() throws XMLDBException {
        System.out.println("---manualRelease");
        Collection test = DatabaseManager.getCollection(baseURI + "/db/rpctest", "admin", "");
        XQueryService service = (XQueryService) test.getService("XQueryService", "1.0");
        ResourceSet result = service.query("//chapter[@xml:id = 'chapter1']");
        Assert.assertEquals(1, result.getSize());

        // clear should release the query result on the server
        result.clear();
View Full Code Here

        }

        public void run() {
            try {
                Collection test = DatabaseManager.getCollection(baseURI + "/db/rpctest", "admin", "");
                XQueryService service = (XQueryService) test.getService("XQueryService", "1.0");
                int n = random.nextInt(DOC_COUNT) + 1;
                service.declareVariable("n", "chapter" + n);
                ResourceSet result = service.query(query);
                Assert.assertEquals(1, result.getSize());
            } catch (XMLDBException e) {
                e.printStackTrace();
                Assert.fail(e.getMessage());
            }
View Full Code Here

  }

  public void testResourceSet() {
    try {
      String query = "//SPEECH[SPEAKER = 'HAMLET']";
      XQueryService service = (XQueryService) testCollection.getService("XQueryService", "1.0");
      service.setProperty("highlight-matches", "none");
      CompiledExpression compiled = service.compile(query);
      ResourceSet result = service.execute(compiled);
     
      assertEquals(result.getSize(), 359);
     
      for (int i = 0; i < result.getSize(); i++) {
        XMLResource r = (XMLResource) result.getResource(i);
View Full Code Here

  }
 
  public void testExternalVar() {
    try {
      String query = XmlRpcTest.QUERY_MODULE_DATA;
      XQueryService service = (XQueryService) testCollection.getService("XQueryService", "1.0");
      service.setProperty("highlight-matches", "none");

      service.setNamespace("tm", "http://exist-db.org/test/module");
      service.setNamespace("tm-query", "http://exist-db.org/test/module/query");
           
      service.declareVariable("tm:imported-external-string", "imported-string-value");
      service.declareVariable("tm-query:local-external-string", "local-string-value");
     
      CompiledExpression compiled = service.compile(query);
      ResourceSet result = service.execute(compiled);
     
      assertEquals(result.getSize(), 2);
     
      for (int i = 0; i < result.getSize(); i++) {
        XMLResource r = (XMLResource) result.getResource(i);
View Full Code Here

    @Test
    public void getContentAsDOM() throws XMLDBException, TransformerConfigurationException, TransformerException {

        Collection testCollection = DatabaseManager.getCollection(ROOT_URI + "/" + TEST_COLLECTION);
        XQueryService service = (XQueryService) testCollection.getService("XQueryService", "1.0");
        ResourceSet result = service.query(XQUERY);
        for(long i = 0; i < result.getSize(); i++) {
            XMLResource r = (XMLResource) result.getResource(i);

            System.out.println("Output of getContent():");
            System.out.println(r.getContent());
View Full Code Here

  private Database database;
  private Collection testCollection;
 
  public void testQueryResults() {
    try {
      XQueryService service = (XQueryService) testCollection.getService("XQueryService", "1.0");
      ResourceSet result = service.query("declare namespace foo=\"http://foo.com\"; //foo:entry");
      Resource resource = result.getMembersAsResource();
      String str = resource.getContent().toString();
      System.out.println(str);
      assertXMLEqual(XML_EXPECTED1, str);
     
      //TODO : THIS IS BUGGY !
      result = service.query("declare namespace config='urn:config'; " +
          "declare namespace c='urn:content'; "  +
          "declare variable $config {<config xmlns='urn:config'>123</config>}; " +
          "declare variable $serverConfig {<serverconfig xmlns='urn:config'>123</serverconfig>}; " +
          "<c:Site xmlns='urn:content' xmlns:c='urn:content'> " +
          "{($config,$serverConfig)} " +
View Full Code Here

        if (args[0].startsWith("pass:")) {
            passwd = args[0].substring(5);
            offset = 1;
        }
        System.setProperty(AutoDeploymentTrigger.AUTODEPLOY_PROPERTY, "off");
        final XQueryService query = initDb(passwd);
//        if (query != null) {
//            try {
//                installApps(query, args, offset);
//            } catch (EXistException e) {
//                System.err.println("An error occurred while installing apps: " + e.getMessage());
View Full Code Here

                admin.setPassword(adminPass);
                System.out.println("Setting admin user password...");
                service.updateAccount(admin);
                root = DatabaseManager.getCollection(URI, "admin", adminPass);
            }
            final XQueryService query = (XQueryService) root.getService("XQueryService", "1.0");
            return query;
        } catch (final Exception e) {
            System.err.println("Caught an exception while initializing db: " + e.getMessage());
            e.printStackTrace();
        }
View Full Code Here

TOP

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

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.