Package org.exist.source

Examples of org.exist.source.FileSource


            // because the target collection does not yet exist
            {ctx.setModuleLoadPath(tempDir.getAbsolutePath());}

        CompiledXQuery compiled;
        try {
            compiled = xqs.compile(ctx, new FileSource(xquery, "UTF-8", false));
            return xqs.execute(compiled, null);
        } catch (final PermissionDeniedException e) {
            throw new PackageException(e.getMessage(), e);
        }
    }
View Full Code Here


                        source = new URLSource( new URL( queryUri ) );
                    }

                } else if( queryFile != null ) {
                    log( "XQuery file " + queryFile.getAbsolutePath(), Project.MSG_DEBUG );
                    source = new FileSource( queryFile, "UTF-8", true );

                } else {
                    log( "XQuery string: " + query, Project.MSG_DEBUG );
                    source = new StringSource( query );
                }
View Full Code Here

        // Try to find the XQuery
        final String qpath = getServletContext().getRealPath(query);
        final File f = new File(qpath);
        if (!(f.canRead() && f.isFile()))
            {throw new ServletException("Cannot read XQuery source from " + f.getAbsolutePath());}
        final FileSource source = new FileSource(f, "UTF-8", true);

        try {
            // Prepare and execute the XQuery
            final Collection collection = DatabaseManager.getCollection(collectionURI.toString(), user, password);
            final XQueryService service = (XQueryService) collection.getService("XQueryService", "1.0");
View Full Code Here

               
              Exception error = null;
                if ("runtime-error".equals(scenario)) {
                  try {
                        //compile
                        CompiledXQuery compiled = xquery.compile(context, new FileSource(caseScript, "UTF8", true));

                        //execute
                        result = xquery.execute(compiled, contextSequence);
                       
                        if (outputFiles.getLength() != 0) {
                            //can be answered
                          for (int i = 0; i < outputFiles.getLength(); i++) {
                              ElementImpl outputFile = (ElementImpl)outputFiles.item(i);
         
                              String compare = outputFile.getAttribute("compare");
                              if (compare != null && compare.equalsIgnoreCase("IGNORE")) {
                                ok = true;
                                break;
                              }
         
                              if (compareResult(script, "XQTS_1_0_3/ExpectedTestResults/"+folder, outputFile, result)) {
                                  ok = true;
                                  break;
                              }
                          }
                        } else {
                          error = catchError(result);
                        }

                  } catch (Exception e) {
                    error = e;
          }
                 
                    if (!ok && error != null && expectedError != null) {// error.getMessage().contains(expectedError)) {
                      ok = true;
                    }
                } else {
                    //compile
                    CompiledXQuery compiled = xquery.compile(context, new FileSource(caseScript, "UTF8", true));

                    //execute
                    result = xquery.execute(compiled, contextSequence);

                    //check answer
View Full Code Here

            if(!f.canRead()) {
                response.setStatus(HttpServletResponse.SC_NOT_FOUND);
                sendError(output, "Cannot read source file", path);
                return;
            }
            source = new FileSource(f, encoding, true);
        }
       
        if (source == null) {
            response.setStatus(HttpServletResponse.SC_NOT_FOUND);
            sendError(output, "Source not found", path);
View Full Code Here

  @Test
  public void run() {
    try {
      XQueryService xqs = (XQueryService) testCollection.getService("XQueryService", "1.0");
      Source query = new FileSource(new File(TEST_QUERY), "UTF-8", false);
      for (File file : files) {
        xqs.declareVariable("doc", file.getName());
        ResourceSet result = xqs.execute(query);
        XMLResource resource = (XMLResource) result.getResource(0);
                System.out.println(resource.getContent());
View Full Code Here

  private static void runTests(List<String> files, String id) {
    try {
      StringBuilder results = new StringBuilder();
      XQueryService xqs = (XQueryService) rootCollection.getService("XQueryService", "1.0");
      Source query = new FileSource(new File("test/src/xquery/runTests.xql"), "UTF-8", false);
      for (String fileName : files) {
        File file = new File(fileName);
        if (!file.canRead()) {
          System.console().printf("Test file not found: %s\n", fileName);
          return;
View Full Code Here

        try {
            StringBuilder fails = new StringBuilder();
            StringBuilder results = new StringBuilder();
            XQueryService xqs = (XQueryService) rootCollection.getService("XQueryService", "1.0");
            Source query = new FileSource(new File("test/src/xquery/runTests.xql"), "UTF-8", false);
            for (File file : files) {
                Document doc = parse(file);

                xqs.declareVariable("doc", doc);
        xqs.declareVariable("id", Sequence.EMPTY_SEQUENCE);
View Full Code Here

            try {
                StringBuilder fails = new StringBuilder();
                StringBuilder results = new StringBuilder();
                XQueryService xqs = (XQueryService) rootCollection.getService("XQueryService", "1.0");
                xqs.setModuleLoadPath(getDirectory());
                Source query = new FileSource(suite, "UTF-8", false);

                ResourceSet result = xqs.execute(query);
                XMLResource resource = (XMLResource) result.getResource(0);
                results.append(resource.getContent()).append('\n');
View Full Code Here

        return execute(compiled, contextSequence);
    }
 
    public Sequence execute(File file, Sequence contextSequence, AccessContext accessCtx) throws XPathException, IOException, PermissionDeniedException {
        final XQueryContext context = new XQueryContext(broker.getBrokerPool(), accessCtx);
        final CompiledXQuery compiled = compile(context, new FileSource(file, "UTF-8", true));
        return execute(compiled, contextSequence);
    }
View Full Code Here

TOP

Related Classes of org.exist.source.FileSource

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.