Package net.sf.saxon.query

Examples of net.sf.saxon.query.DynamicQueryContext


    /**
     * Creates a dynamic context for the given exchange
     */
    protected DynamicQueryContext createDynamicContext(Exchange exchange) throws Exception {
        Configuration config = getConfiguration();
        DynamicQueryContext dynamicQueryContext = new DynamicQueryContext(config);

        Message in = exchange.getIn();

        Item item = in.getBody(Item.class);
        if (item != null) {
            dynamicQueryContext.setContextItem(item);
        } else {
            Source source = in.getBody(Source.class);
            if (source == null) {
                source = converter.toSource(converter.createDocument());
            }
            DocumentInfo doc = getStaticQueryContext().buildDocument(source);
            dynamicQueryContext.setContextItem(doc);
        }
       
        configureQuery(dynamicQueryContext, exchange);
        // call the reset if the in message body is StreamCache
        MessageHelper.resetStreamCache(exchange.getIn());
View Full Code Here


    /**
     * Creates a dynamic context for the given exchange
     */
    protected DynamicQueryContext createDynamicContext(E exchange) throws Exception {
        Configuration config = getConfiguration();
        DynamicQueryContext dynamicQueryContext = new DynamicQueryContext(config);

        Source source = exchange.getIn().getBody(Source.class);
        if (source == null) {
            source = converter.toSource(converter.createDocument());
        }

        DocumentInfo doc = getStaticQueryContext().buildDocument(source);
        dynamicQueryContext.setContextItem(doc);
        configureQuery(dynamicQueryContext, exchange);
        return dynamicQueryContext;
    }
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) {
            throw newXQException(e);
View Full Code Here

    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) {
            throw newXQException(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

    boolean closed;

    SaxonXQExpression(SaxonXQConnection connection) {
        this.connection = connection;
        config = connection.getConfiguration();
        context = new DynamicQueryContext(config);
        sqc = new StaticQueryContext(config);
    }
View Full Code Here

    }

    SaxonXQExpression(SaxonXQConnection connection, SaxonXQStaticContext staticContext) {
        this.connection = connection;
        config = connection.getConfiguration();
        context = new DynamicQueryContext(config);
        sqc = staticContext.getSaxonStaticQueryContext();
    }
View Full Code Here

     */

    protected XQueryEvaluator(Processor processor, XQueryExpression expression) {
        this.processor = processor;
        this.expression = expression;
        this.context = new DynamicQueryContext(expression.getExecutable().getConfiguration());
    }
View Full Code Here

    public List execQuery(Object node, Map variableBindings)
    {
        try {
            Node context_node = (Node) node;
            DynamicQueryContext dynamicContext =
                    new DynamicQueryContext(config);
            dynamicContext.setContextNode(_stcContext.
                    buildDocument(new DOMSource(context_node)));
            dynamicContext.setParameter(_contextVar,
                    dynamicContext.getContextItem());
            // Set the other variables
            if (variableBindings != null)
                for (Iterator it = variableBindings.entrySet().iterator();
                    it.hasNext(); )
                {
                    Map.Entry entry = (Map.Entry) it.next();
                    if (entry.getValue() instanceof XmlTokenSource)
                    {
                        Object paramObject;
                        // Saxon 8.6.1 requires that the Node be wrapped
                        // into a DOMSource, while later versions require that
                        // it not be
                        if (needsDomSourceWrapping)
                            paramObject = new DOMSource(((XmlTokenSource)
                                entry.getValue()).getDomNode());
                        else
                            paramObject = ((XmlTokenSource) entry.getValue()).
                                getDomNode();
                        dynamicContext.setParameter((String) entry.getKey(),
                                paramObject);
                    }
                    else if (entry.getValue() instanceof String)
                    dynamicContext.setParameter((String) entry.getKey(),
                        entry.getValue());
                }

            // After 8.3(?) Saxon nodes no longer implement Dom.
            // The client needs saxon8-dom.jar, and the code needs
View Full Code Here

            config = exp.getStaticContext().getConfiguration();
        }

        Object[] params = prepareParameters(payload, config, props);

        DynamicQueryContext dynamicContext = new DynamicQueryContext(config);

        // Setting the parameters for function invocation
        String methodName = theMethod.getName();
        for (int i = 0; i < params.length; i++) {
            dynamicContext.setParameter(methodName + "_" + i, params[i]);
        }

        // Setting references
        for (Map.Entry<String, Object> entry : referenceProxies.entrySet()) {
            dynamicContext.setParameter(entry.getKey(), entry.getValue());
        }

        // Setting properties
        for (Map.Entry<String, Object> entry : properties.entrySet()) {
            dynamicContext.setParameter(entry.getKey(), transformProperty(entry.getValue(), config));
        }

        SequenceIterator iterator = null;
        Configuration oldConfigValue = SaxonDataBindingHelper.CURR_EXECUTING_CONFIG;
        SaxonDataBindingHelper.CURR_EXECUTING_CONFIG = config;
View Full Code Here

TOP

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

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.