Examples of CompiledXQuery


Examples of org.exist.xquery.CompiledXQuery

        final XQuery xquery = broker.getXQueryService();
    final XQueryPool pool = xquery.getXQueryPool();
        XQueryContext context;
       
        //try and get pre-compiled XQuery from the cache
        CompiledXQuery compiled = pool.borrowCompiledXQuery(broker, xqSource);
       
        //Create the context and set a header to indicate cache status
        if(compiled == null)
        {
          context = xquery.newContext(AccessContext.REST);
          //response.setHeader("X-XQuery-Cached", "false");
      }
        else
      {
          context = compiled.getContext();
          //response.setHeader("X-XQuery-Cached", "true");
        }
       
        //Setup the context
        declareVariables(context, request, response);
View Full Code Here

Examples of org.exist.xquery.CompiledXQuery

    {
      //Get the internal description for the function requested by SOAP (should be in the cache)
      final XQWSDescription description = getXQWSDescription(broker, path, request);
     
      //Create an XQuery to call the XQWS function
      final CompiledXQuery xqCallXQWS = XQueryExecuteXQWSFunction(broker, nSOAPFunction, description, request, response);
     
      //xqCallXQWS
      final XQuery xqueryService = broker.getXQueryService();
      final Sequence xqwsResult = xqueryService.execute(xqCallXQWS, null);
     
View Full Code Here

Examples of org.exist.xquery.CompiledXQuery

        }
    }

    private Sequence execute(DBBroker broker, XQuery xqueryService, Source querySource, XQueryContext innerContext, Sequence exprContext, boolean cache) throws XPathException {

        CompiledXQuery compiled = null;
        final XQueryPool pool = xqueryService.getXQueryPool();

        try {
            compiled = cache ? pool.borrowCompiledXQuery(broker, querySource) : null;
            if(compiled == null) {
                compiled = xqueryService.compile(innerContext, querySource);
            } else {
                compiled.getContext().updateContext(innerContext);
            }

            Sequence sequence = xqueryService.execute(compiled, exprContext, false);
            ValueSequence newSeq = new ValueSequence();
            newSeq.keepUnOrdered(unordered);
            boolean hasSupplements = false;
            for (int i = 0;  i < sequence.getItemCount(); i++) {
                //if (sequence.itemAt(i) instanceof StringValue) {
                if (Type.subTypeOf(sequence.itemAt(i).getType(),Type.STRING)) {
                    newSeq.add(new StringValue(((StringValue) sequence.itemAt(i)).getStringValue(true)));
                    hasSupplements = true;
                } else {
                    newSeq.add(sequence.itemAt(i));
                }
            }

            if(hasSupplements) {
                sequence = newSeq;
            }

            return sequence;

        } catch(final IOException ioe) {
            throw new XPathException(this, ioe);
        } catch (final PermissionDeniedException e) {
            throw new XPathException(this, e);
    } finally {
            if(compiled != null) {
                if(cache) {
                    pool.returnCompiledXQuery(querySource, compiled);
                } else {
                    compiled.reset();
                }
            }
        }
    }
View Full Code Here

Examples of org.exist.xquery.CompiledXQuery

       
            // 3) Get the XQWS Namespace
            xqwsNamespace = getXQWSNamespace(xqwsData);
           
            // 4) Compile a Simple XQuery to access the module
            final CompiledXQuery compiled = XQueryIncludeXQWS(broker, docXQWS.getFileURI(), xqwsNamespace, docXQWS.getCollection().getURI());
           
            // 5) Inspect the XQWS and its function signatures and create a small XML document to represent it
            modXQWS = compiled.getContext().getModule(xqwsNamespace.getNamespaceURI());
            docXQWSDescription = describeWebService(modXQWS, xqwsFileURI, request, XQWSPath, null, null);
      }
View Full Code Here

Examples of org.exist.xquery.CompiledXQuery

        final XmldbURI pathUri = XmldbURI.create(path);
        try {
            final Source source = new StringSource(query);
            final XQuery xquery = broker.getXQueryService();
            final XQueryPool pool = xquery.getXQueryPool();
            CompiledXQuery compiled = pool.borrowCompiledXQuery(broker, source);

            XQueryContext context;
            if (compiled == null) {
                context = xquery.newContext(AccessContext.REST);
            } else {
                context = compiled.getContext();
            }

            context.setStaticallyKnownDocuments(new XmldbURI[]{pathUri});
            context.setBaseURI(new AnyURIValue(pathUri.toString()));

            declareNamespaces(context, namespaces);
            declareVariables(context, variables, request, response);

            if (compiled == null) {
                compiled = xquery.compile(context, source);
            } else {
                compiled.getContext().updateContext(context);
                context.getWatchDog().reset();
            }

            try {
                final long startTime = System.currentTimeMillis();
View Full Code Here

Examples of org.exist.xquery.CompiledXQuery

        final Source source = new DBSource(broker, (BinaryDocument) resource, true);
        final XQuery xquery = broker.getXQueryService();
        final XQueryPool pool = xquery.getXQueryPool();
        XQueryContext context;

        CompiledXQuery compiled = pool.borrowCompiledXQuery(broker, source);
        if (compiled == null) {
            // special header to indicate that the query is not returned from
            // cache
            response.setHeader("X-XQuery-Cached", "false");
            context = xquery.newContext(AccessContext.REST);

        } else {
            response.setHeader("X-XQuery-Cached", "true");
            context = compiled.getContext();
        }

        // TODO: don't hardcode this?
        context.setModuleLoadPath(
                XmldbURI.EMBEDDED_SERVER_URI.append(
View Full Code Here

Examples of org.exist.xquery.CompiledXQuery

        final URLSource source = new URLSource(this.getClass().getResource("run-xproc.xq"));
        final XQuery xquery = broker.getXQueryService();
        final XQueryPool pool = xquery.getXQueryPool();
        XQueryContext context;
        CompiledXQuery compiled = pool.borrowCompiledXQuery(broker, source);
        if (compiled == null) {
            context = xquery.newContext(AccessContext.REST);
        } else {
            context = compiled.getContext();
        }

        context.declareVariable("pipeline", resource.getURI().toString());
       
        final String stdin = request.getParameter("stdin");
View Full Code Here

Examples of org.exist.xquery.CompiledXQuery

  public void getEntryById(DBBroker broker, String path, String id,
      OutgoingMessage response) throws EXistException,
      BadRequestException, PermissionDeniedException {
    final XQuery xquery = broker.getXQueryService();
    CompiledXQuery feedQuery = xquery.getXQueryPool().borrowCompiledXQuery(
        broker, entryByIdSource);

    XQueryContext context;
    if (feedQuery == null) {
      context = xquery.newContext(AccessContext.REST);
      try {
        feedQuery = xquery.compile(context, entryByIdSource);
      } catch (final XPathException ex) {
        throw new EXistException("Cannot compile xquery "
            + entryByIdSource.getURL(), ex);
      } catch (final IOException ex) {
        throw new EXistException(
            "I/O exception while compiling xquery "
                + entryByIdSource.getURL(), ex);
      }
    } else {
      context = feedQuery.getContext();
    }
    context.setStaticallyKnownDocuments(new XmldbURI[] { XmldbURI.create(
        path).append(AtomProtocol.FEED_DOCUMENT_NAME) });

    try {
View Full Code Here

Examples of org.exist.xquery.CompiledXQuery

  public void getFeed(DBBroker broker, String path, OutgoingMessage response)
      throws EXistException, BadRequestException,
      PermissionDeniedException {
   
    final XQuery xquery = broker.getXQueryService();
    CompiledXQuery feedQuery = xquery.getXQueryPool().borrowCompiledXQuery(
        broker, getFeedSource);

    XQueryContext context;
    if (feedQuery == null) {
      context = xquery.newContext(AccessContext.REST);
      try {
        feedQuery = xquery.compile(context, getFeedSource);
      } catch (final XPathException ex) {
        throw new EXistException("Cannot compile xquery "
            + getFeedSource.getURL(), ex);
      } catch (final IOException ex) {
        throw new EXistException(
            "I/O exception while compiling xquery "
                + getFeedSource.getURL(), ex);
      }
    } else {
      context = feedQuery.getContext();
    }
    context.setStaticallyKnownDocuments(
      new XmldbURI[] {
          XmldbURI.create(path).append(AtomProtocol.FEED_DOCUMENT_NAME)
      }
View Full Code Here

Examples of org.exist.xquery.CompiledXQuery

                // Allow use of modules with relative paths
                String moduleLoadPath = StringUtils.substringBeforeLast(path, "/");
                context.setModuleLoadPath(moduleLoadPath);

                // Compile query
                CompiledXQuery compiledQuery = service.compile(context, source);

                LOG.info(String.format("Starting Xquery at '%s'", path));

                // Finish preparation
                context.prepareForExecution();
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.