Package org.xmldb.api.modules

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


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

                service.declareVariable("filename", generatedFiles[i].getName());
                service.declareVariable("count", new Integer(i));
                ResourceSet result = service.execute(compiled);

                Writer out = new OutputStreamWriter(new FileOutputStream(generatedFiles[i]), "UTF-8");
                SAXSerializer sax = new SAXSerializer(out, outputProps);
                for (ResourceIterator iter = result.getIterator(); iter.hasMoreResources(); ) {
                    XMLResource r = (XMLResource) iter.nextResource();
View Full Code Here


        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());
    }

    @Test
    public void queryResource() throws XMLDBException {
View Full Code Here

    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

           
      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

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

            "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);
        Node node = r.getContentAsDOM();
        if (node.getNodeType() == Node.DOCUMENT_NODE) {
            node = node.getFirstChild();
View Full Code Here

        //TODO : we should virtually pass any kind of value
        service.declareVariable("local:string", new Integer(1));

        String message = "";
        try {
            service.execute(expr);
            System.out.println(query);
        } catch (XMLDBException e) {
            e.printStackTrace();
            message = e.getMessage();
        }
View Full Code Here

        service.declareVariable("x", "1");

        message = "";
        try {
            System.out.println(query);
            service.execute(expr);
        } catch (XMLDBException e) {
            e.printStackTrace();
            message = e.getMessage();
        }
        assertTrue(message.indexOf("XPTY0004") > -1);
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.