Package net.sf.saxon.query

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


    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

    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

     */
    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

    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

        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

        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

        xqExpression += "\r\n<dummy></dummy>";

        Configuration config = new Configuration();
        StaticQueryContext sqc = new StaticQueryContext(config);
        XQueryExpression exp = null;
        try {
            exp = sqc.compileQuery(xqExpression);
        } catch (XPathException e) {
            throw new ContributionResolveException(e);
        }
View Full Code Here

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

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

    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

TOP

Related Classes of net.sf.saxon.query.XQueryExpression

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.