Package net.sf.saxon.query

Examples of net.sf.saxon.query.StaticQueryContext.compileQuery()


     */

    public static void exampleWithParam() throws XPathException {
        final Configuration config = new Configuration();
        final StaticQueryContext sqc = new StaticQueryContext(config);
        final XQueryExpression exp = sqc.compileQuery("declare variable $in as xs:integer external;" +
                "$in * $in");

        final DynamicQueryContext dynamicContext = new DynamicQueryContext(config);
        dynamicContext.setParameter("in", new Long(17));
        final Long result = (Long)exp.evaluateSingle(dynamicContext);
View Full Code Here


    public static void examplePipeline() throws XPathException {
        final Configuration config = new Configuration();

        // Compile the first query
        final StaticQueryContext sqc1 = new StaticQueryContext(config);
        final XQueryExpression exp1 = sqc1.compileQuery(
                "declare variable $in as xs:integer external;" +
                "document{ <a>{$in * $in}</a> }"
        );

        // Compile the second query (each query should have its own static context)
View Full Code Here

                "document{ <a>{$in * $in}</a> }"
        );

        // Compile the second query (each query should have its own static context)
        final StaticQueryContext sqc2 = new StaticQueryContext(config);
        final XQueryExpression exp2 = sqc2.compileQuery(
                "/a + 5"
        );

        // Run the first query
        final DynamicQueryContext dynamicContext = new DynamicQueryContext(config);
View Full Code Here

     * checking of the supplied arguments
     */

    public static void exampleDirectFunction() throws XPathException {
        final StaticQueryContext sqc = new StaticQueryContext(new Configuration());
        final XQueryExpression exp1 = sqc.compileQuery("declare namespace f='f.ns';" +
                "declare function f:t1($v1 as xs:integer, $v2 as xdt:untypedAtomic*) { " +
                "   $v1 div $v2" +
                "};" +
                "10");

View Full Code Here

        XQueryExpression exp = implementation.getCompiledExpressionsCache().get(xqExpression);
        if (exp == null) {
            config = new Configuration();
            StaticQueryContext sqc = new StaticQueryContext(config);
            exp = sqc.compileQuery(xqExpression);
            implementation.getCompiledExpressionsCache().put(xqExpression, exp);
        } else {
            config = exp.getStaticContext().getConfiguration();
        }
View Full Code Here

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

        if (exp == null) {
View Full Code Here

   
    XQueryExpression exp = implementation.getCompiledExpressionsCache().get(xqExpression);
    if(exp == null) {
      config = new Configuration();
      StaticQueryContext sqc = new StaticQueryContext(config);
      exp = sqc.compileQuery(xqExpression);
      implementation.getCompiledExpressionsCache().put(xqExpression, exp);
    } else {
      config = exp.getStaticContext().getConfiguration();
    }
   
View Full Code Here

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

        // Create a dummy main query module and compile it
        StaticQueryContext sqc = new StaticQueryContext(getConfiguration());
        sqc.setExecutable(getExecutable());
        sqc.setBaseURI(getBaseURI());
        String mainModule = "import module namespace m = \"" + moduleURI + "\" at \"" + href + "\"; ()";
        XQueryExpression exp = sqc.compileQuery(mainModule);
        return exp.getStaticContext();
    }


    public Expression compile(Executable exec) throws XPathException {
View Full Code Here

    public XQPreparedExpression prepareExpression(InputStream xquery, XQStaticContext properties) throws XQException {
        checkNotClosed();
        try {
            StaticQueryContext sqc = ((SaxonXQStaticContext)properties).getSaxonStaticQueryContext();
            XQueryExpression exp = sqc.compileQuery(xquery, null);
            DynamicQueryContext dqc = new DynamicQueryContext(config);
            return new SaxonXQPreparedExpression(this, exp, dqc);
        } catch (XPathException e) {
            throw newXQException(e);
        } catch (IOException e) {
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.