Package org.xmldb.api.modules

Examples of org.xmldb.api.modules.XQueryService.compile()


        System.out.println("query: " + query);
        try {
            XQueryService service = (XQueryService) collection.getService("XQueryService", "1.0");
            service.declareVariable("filename", "");
            service.declareVariable("count", "0");
            CompiledExpression compiled = service.compile(query);

            for (int i = 0; i < count; i++) {
                generatedFiles[i] = File.createTempFile(prefix, ".xml");

                service.declareVariable("filename", generatedFiles[i].getName());
View Full Code Here


        final DocumentBuilder builder = factory.newDocumentBuilder();
        final InputSource source = new InputSource(new StringReader(strings));
        final Document doc = builder.parse(source);

        final XQueryService service = (XQueryService) testCollection.getService("XQueryService", "1.0");
        final CompiledExpression expr = service.compile("declare variable $local:node external; $local:node//string");
        service.declareVariable("local:node", doc.getDocumentElement());
        final ResourceSet result = service.execute(expr);
        assertEquals(3, result.getSize());
    }
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++) {
View Full Code Here

      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++) {
View Full Code Here

            storeXMLStringAndGetQueryService("strings.xml", strings);

        String query =
            "declare variable $x external;" +
            "$x";
        CompiledExpression expr = service.compile(query);
        //Do not declare the variable...
        boolean exceptionThrown = false;
        try {
            service.execute(expr);
        } catch (XMLDBException e) {
View Full Code Here

        assertTrue("Expected XPTY0002", exceptionThrown);

        query =
            "declare variable $local:string external;" +
            "/test/string[. = $local:string]";
        expr = service.compile(query);
        service.declareVariable("local:string", "Hello");

        ResourceSet result = service.execute(expr);

        final XMLResource r = (XMLResource) result.getResource(0);
View Full Code Here

        service = storeXMLStringAndGetQueryService("strings.xml", strings);

        query =
            "declare variable $local:string as xs:string external;" +
            "$local:string";
        expr = service.compile(query);
        //TODO : we should virtually pass any kind of value
        service.declareVariable("local:string", new Integer(1));

        String message = "";
        try {
View Full Code Here

        service = storeXMLStringAndGetQueryService("strings.xml", strings);

        query =
            "declare variable $x as xs:integer external; " +
            "$x";
        expr = service.compile(query);
        //TODO : we should virtually pass any kind of value
        service.declareVariable("x", "1");

        message = "";
        try {
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.