Package net.sf.saxon.trans

Examples of net.sf.saxon.trans.XPathException


     *         of class XPathProcessor
     */

    public List evaluate(DynamicQueryContext env) throws XPathException {
        if (isUpdating) {
            throw new XPathException("Cannot call evaluate() on an updating query");
        }
        SequenceIterator iterator = iterator(env);
        ArrayList list = new ArrayList(100);
        while (true) {
            Item item = iterator.next();
View Full Code Here


     */

    public void checkArguments(ExpressionVisitor visitor) throws XPathException {
        super.checkArguments(visitor);
        if (operation==BOOLEAN || operation==NOT) {
            XPathException err = TypeChecker.ebvError(argument[0], visitor.getConfiguration().getTypeHierarchy());
            if (err != null) {
                err.setLocator(this);
                throw err;
            }
            Optimizer opt = visitor.getConfiguration().getOptimizer();
            argument[0] = ExpressionTool.unsortedIfHomogeneous(opt, argument[0]);
        }
View Full Code Here

     *         the {@link XQueryExpression#evaluate evaluate} method
     */

    public Object evaluateSingle(DynamicQueryContext env) throws XPathException {
        if (isUpdating) {
            throw new XPathException("Cannot call evaluateSingle() on an updating query");
        }
        SequenceIterator iterator = iterator(env);
        Item item = iterator.next();
        if (item == null) {
            return null;
View Full Code Here

     *                        when the individual items of the result are accessed using the returned iterator.
     */

    public SequenceIterator iterator(DynamicQueryContext env) throws XPathException {
        if (isUpdating) {
            throw new XPathException("Cannot call iterator() on an updating query");
        }
        if (!env.getConfiguration().isCompatible(getExecutable().getConfiguration())) {
            throw new XPathException("The query must be compiled and executed under the same Configuration");
        }
        Controller controller = newController();
        initializeController(env, controller);

        try {
            Item contextItem = env.getContextItem();

            //Bindery bindery = controller.getBindery();
            //bindery.openStackFrame();
            controller.defineGlobalParameters();
            XPathContextMajor context = controller.newXPathContext();

            if (contextItem != null) {
                if (!staticContext.getUserQueryContext().getRequiredContextItemType().matchesItem(
                        contextItem, false, env.getConfiguration())) {
                    throw new XPathException("The supplied context item does not match the required context item type");
                }
                UnfailingIterator single = SingletonIterator.makeIterator(contextItem);
                single.next();
                context.setCurrentIterator(single);
                controller.setInitialContextItem(contextItem);
            }

            // In tracing/debugging mode, evaluate all the global variables first
            if (controller.getTraceListener() != null) {
                controller.preEvaluateGlobals(context);
            }

            context.openStackFrame(stackFrameMap);

            SequenceIterator iterator = expression.iterate(context);
            return new ErrorReportingIterator(iterator, controller.getErrorListener());
        } catch (XPathException err) {
            TransformerException terr = err;
            while (terr.getException() instanceof TransformerException) {
                terr = (TransformerException)terr.getException();
            }
            XPathException de = XPathException.makeXPathException(terr);
            controller.reportFatalError(de);
            throw de;
        }
    }
View Full Code Here

     * @throws XPathException if the query fails.
     */

    public void run(DynamicQueryContext env, Result result, Properties outputProperties) throws XPathException {
        if (isUpdating) {
            throw new XPathException("Cannot call run() on an updating query");
        }
        if (!env.getConfiguration().isCompatible(getExecutable().getConfiguration())) {
            throw new XPathException("The query must be compiled and executed under the same Configuration");
        }
        Controller controller = newController();
        initializeController(env, controller);

        if (allowDocumentProjection) {
            controller.setUseDocumentProjection(getPathMap());
        }
        Properties actualProperties = validateOutputProperties(controller, outputProperties);

        //controller.defineGlobalParameters();

        XPathContextMajor context = initialContext(env, controller);

        // In tracing/debugging mode, evaluate all the global variables first
        TraceListener tracer = controller.getTraceListener();
        if (tracer != null) {
            controller.preEvaluateGlobals(context);
            tracer.open();
        }

        context.openStackFrame(stackFrameMap);

        boolean mustClose = (result instanceof StreamResult &&
                ((StreamResult)result).getOutputStream() == null);
        SerializerFactory sf = context.getConfiguration().getSerializerFactory();
        PipelineConfiguration pipe = controller.makePipelineConfiguration();
        pipe.setHostLanguage(Configuration.XQUERY);
        Receiver receiver = sf.getReceiver(result, pipe, actualProperties);
        context.changeOutputDestination(receiver, true,
                Validation.PRESERVE, null);
        context.getReceiver().open();

        // Run the query
        try {
            expression.process(context);
        } catch (XPathException err) {
            controller.reportFatalError(err);
            throw err;
        }

        if (tracer != null) {
            tracer.close();
        }

        context.getReceiver().close();
        if (mustClose) {
            OutputStream os = ((StreamResult)result).getOutputStream();
            if (os != null) {
                try {
                    os.close();
                } catch (java.io.IOException err) {
                    throw new XPathException(err);
                }
            }
        }
    }
View Full Code Here

        public Object convert(ValueRepresentation value, Class targetClass, XPathContext context) throws XPathException {
            try {
                return new URI(value.getStringValue());
            } catch (URISyntaxException err) {
                throw new XPathException("The anyURI value '" + value + "' is not an acceptable Java URI");
            }
        }
View Full Code Here

     * @see Configuration#setLazyConstructionMode(boolean)
     */

    public void pull(DynamicQueryContext dynamicEnv, Result destination, Properties outputProperties) throws XPathException {
        if (isUpdating) {
            throw new XPathException("Cannot call pull() on an updating query");
        }
        Configuration config = dynamicEnv.getConfiguration();
        try {
            Controller controller = newController();
            //initializeController(dynamicEnv, controller);
View Full Code Here

     * @return an EventIterator representing the results of the query as a sequence of events
     */

    public EventIterator iterateEvents(Controller controller, DynamicQueryContext dynamicEnv) throws XPathException {
        if (isUpdating) {
            throw new XPathException("Cannot call iterateEvents() on an updating query");
        }
        initializeController(dynamicEnv, controller);

        XPathContextMajor context = initialContext(dynamicEnv, controller);

View Full Code Here

     * @throws XPathException if evaluation of the update query fails, or it this is not an updating query
     */

    public Set runUpdate(DynamicQueryContext dynamicEnv) throws XPathException {
        if (!isUpdating) {
            throw new XPathException("Calling runUpdate() on a non-updating query");
        }

        Configuration config = executable.getConfiguration();
        Controller controller = newController();
        initializeController(dynamicEnv, controller);
View Full Code Here

     * @throws XPathException if evaluation of the update query fails, or it this is not an updating query
     */

    public void runUpdate(DynamicQueryContext dynamicEnv, UpdateAgent agent) throws XPathException {
        if (!isUpdating) {
            throw new XPathException("Calling runUpdate() on a non-updating query");
        }

        Configuration config = executable.getConfiguration();
        Controller controller = newController();
        initializeController(dynamicEnv, controller);
View Full Code Here

TOP

Related Classes of net.sf.saxon.trans.XPathException

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.