Package net.sf.saxon.query

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


    public XQPreparedExpression prepareExpression(Reader xquery, XQStaticContext properties) throws XQException {
        checkNotClosed();
        try {
            StaticQueryContext sqc = ((SaxonXQStaticContext)properties).getSaxonStaticQueryContext();
            XQueryExpression exp = sqc.compileQuery(xquery);
            DynamicQueryContext dqc = new DynamicQueryContext(config);
            return new SaxonXQPreparedExpression(this, exp, dqc);
        } catch (XPathException e) {
            throw newXQException(e);
        } catch (IOException e) {
View Full Code Here


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

    public static XQueryExpression compileQuery(XPathContext context, String query) throws XPathException {
        if (query == null) {
            return null;
        }
        StaticQueryContext sqc = new StaticQueryContext(context.getConfiguration());
        return sqc.compileQuery(query);

    }

    /**
     * Run a previously-compiled query. The initial context item for the query is taken from the context
View Full Code Here

            XPathExpression xpexp = xpath.createExpression(args[1]);
            exp = xpexp.getInternalExpression();
        } else if (args[0].equals("xquery")) {
            StaticQueryContext sqc = new StaticQueryContext(config);
            sqc.setBaseURI(new File(args[1]).toURI().toString());
            XQueryExpression xqe = sqc.compileQuery(new FileReader(args[1]));
            exp = xqe.getExpression();
        } else {
            throw new IllegalArgumentException("first argument must be xpath or xquery");
        }
        exp.explain(System.err);
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

  public void testExecuteWrongQuery() throws Exception {
    try {
      XQConnection connection = new XQConnection();
      StaticQueryContext mockContext = mock( StaticQueryContext.class );
      when( mockContext.compileQuery( TEST_QUERY ) ).thenThrow( new XPathException( "Test XPathException" ) );
      connection.sqc = mockContext;

      IPentahoResultSet data = connection.executeQuery( TEST_QUERY );
      fail( "Should throw XPathException" );
    } catch ( XPathException e ) {
View Full Code Here

      properties.setProperty( IPentahoConnection.QUERY_KEY, TEST_QUERY );
      isConnected = connection.connect( properties );
      assertTrue( isConnected );

      StaticQueryContext mockContext = mock( StaticQueryContext.class );
      when( mockContext.compileQuery( TEST_QUERY ) ).thenThrow( new XPathException( "Test XPathException" ) );
      connection.sqc = mockContext;

      isConnected = connection.connect( properties );
      assertFalse( isConnected );
    } catch ( Exception 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.