Examples of XQueryExpression


Examples of ch.ethz.mxquery.core.XQueryExpression

    } else {
      System.out.println("Micro XQuery 0.1\n Usage java -jar mxquery.jar querystring or java -jar mxquery.jar queryfile\n Executing sample query\n ");
    }

    File file = new File(query);
    XQueryExpression exp;
    if (file.exists()) {
      exp = executor.prepareQuery(FileReader.UriToString(query));
    } else {
      exp = executor.prepareQuery(query);
    }
View Full Code Here

Examples of ch.ethz.mxquery.core.XQueryExpression

    executor.doQuery(exp);
    System.out.println(executor.getResultBuffer().toString());
  }

  public void doQuery(String query) throws Exception {
    XQueryExpression expr = prepareQuery(query);
    doQuery(expr);
  }
View Full Code Here

Examples of ch.ethz.mxquery.core.XQueryExpression

    doQuery(expr);
  }

  public XQueryExpression prepareQuery(String query) throws Exception {
    System.out.println("Executing Query: \n'" + query + "'");
    XQueryExpression expr = runtime.prepareQuery(query);
    return expr;
  }
View Full Code Here

Examples of net.sf.saxon.query.XQueryExpression

        queryFile = XMARK_HOME + '/' + queryFile;
        final Configuration config = new Configuration();
        config.setHostLanguage(Configuration.XQUERY);
        final StaticQueryContext staticContext = new StaticQueryContext(config);
        staticContext.setBaseURI(new File(queryFile).toURI().toString());
        XQueryExpression exp = staticContext.compileQuery(IOUtils.toString(new FileInputStream(queryFile)));
        final DynamicQueryContext dynamicContext = new DynamicQueryContext(config);
        StringWriter res_sw = new StringWriter();
        Properties props = new Properties();
        //props.setProperty(OutputKeys.METHOD, "text");
        props.setProperty(SaxonOutputKeys.WRAP, "no");
        props.setProperty(OutputKeys.INDENT, "no");
        props.setProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
        exp.run(dynamicContext, new StreamResult(res_sw), props);
        String swresult = sw.toString();
        long used = SystemUtils.getHeapUsedMemory();
        stdbuf.append(", used(before GC): " + StringUtils.displayBytesSize(used));
        if(RUN_ONLY) {
            res_sw.close();
View Full Code Here

Examples of net.sf.saxon.query.XQueryExpression

    private static String invokeQueryBySaxon(String query) throws XPathException {
        Configuration config = new Configuration();
        config.setHostLanguage(Configuration.XQUERY);
        StaticQueryContext staticContext = new StaticQueryContext(config);
        XQueryExpression exp = staticContext.compileQuery(query);
        DynamicQueryContext dynamicContext = new DynamicQueryContext(config);
        StringWriter res_sw = new StringWriter();
        Properties props = new Properties();
        props.setProperty(SaxonOutputKeys.WRAP, "no");
        props.setProperty(OutputKeys.INDENT, "no");
        props.setProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
        exp.run(dynamicContext, new StreamResult(res_sw), props);
        return res_sw.toString();
    }
View Full Code Here

Examples of net.sf.saxon.query.XQueryExpression

    public Node evaluateAsDOM(Exchange exchange) throws Exception {
        initialize(exchange);

        DOMResult result = new DOMResult();
        DynamicQueryContext context = createDynamicContext(exchange);
        XQueryExpression expression = getExpression();
        expression.pull(context, result, properties);
        return result.getNode();
    }
View Full Code Here

Examples of net.sf.saxon.query.XQueryExpression

     */
    public static ListVariable evaluateXPath(String xpath, String xml, RuntimeConfig runtimeConfig) throws XPathException {
        StaticQueryContext sqc = runtimeConfig.getStaticQueryContext();
        Configuration config = sqc.getConfiguration();

        XQueryExpression exp = runtimeConfig.getXQueryExpressionPool().getCompiledExpression(xpath);
        DynamicQueryContext dynamicContext = new DynamicQueryContext(config);
        StringReader reader = new StringReader(xml);

        dynamicContext.setContextItem(sqc.buildDocument(new StreamSource(reader)));

View Full Code Here

Examples of net.sf.saxon.query.XQueryExpression

    public synchronized XQueryExpression getCompiledExpression(String query) throws XPathException {
        if ( pool.containsKey(query) ) {
            return (XQueryExpression) pool.get(query);
        } else {
            XQueryExpression exp = sqc.compileQuery(query);
            pool.put(query, exp);
            return exp;
        }
    }
View Full Code Here

Examples of net.sf.saxon.query.XQueryExpression

        RuntimeConfig runtimeConfig = scraper.getRuntimeConfig();
        final StaticQueryContext sqc = runtimeConfig.getStaticQueryContext();
        final Configuration config = sqc.getConfiguration();

      try {
          final XQueryExpression exp = runtimeConfig.getXQueryExpressionPool().getCompiledExpression(xqExpression);
        final DynamicQueryContext dynamicContext = new DynamicQueryContext(config);

            // define external parameters
            for (int i = 0; i < externalParamDefs.length; i++) {
                XQueryExternalParamDef externalParamDef = externalParamDefs[i];
View Full Code Here

Examples of net.sf.saxon.query.XQueryExpression

        LOG.debug("evaluateAsDOM: {} for exchange: {}", expression, exchange);
        initialize(exchange);

        DOMResult result = new DOMResult();
        DynamicQueryContext context = createDynamicContext(exchange);
        XQueryExpression expression = getExpression();
        expression.pull(context, result, properties);
        return result.getNode();
    }
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.