Package net.sf.saxon

Examples of net.sf.saxon.Controller


     * Construct a new context as a copy of another. The new context is effectively added
     * to the top of a stack, and contains a pointer to the previous context
     */

    public XPathContextMajor newContext() {
        Controller controller = new Controller(config);
        return controller.newXPathContext();
//        notAllowed();
//        return null;
    }
View Full Code Here


        if (templates == null) {
            configureLiaison(stylesheet);
        }

        Controller transformer = (Controller)templates.newTransformer();

        if (fileNameParameter != null) {
            transformer.setParameter(fileNameParameter, xmlFile);
        }
        if (fileDirParameter != null) {
            transformer.setParameter(fileDirParameter, baseDir.getAbsolutePath());
        }

        try {
            long styleSheetLastModified = stylesheet.getLastModified();
            inF = new File(baseDir, xmlFile);
View Full Code Here

    private void transform(File in, File out) {
        if (templates == null) {
            throw new BuildException("No transformer has been created");
        }
        try {
            Controller transformer = createTransformer(templates);
            Source ss = new StreamSource(in);
            Result sr = new StreamResult(out);
            transformer.transform(ss, sr);
        } catch (TransformerException ex) {
            log("Failed to transform " + in, Project.MSG_INFO);
            if (out != null) {
                out.delete();
            }
View Full Code Here

            throw new BuildException(ex);
        }
    }

    private Controller createTransformer(PreparedStylesheet pss) throws XPathException {
        Controller transformer = (Controller)pss.newTransformer();
        transformer.setInitialMode(initialMode);
        transformer.setInitialTemplate(initialTemplate);
        if (tracing) {
            transformer.addTraceListener(new XSLTTraceListener());
        }
        if (recoveryPolicy != null) {
            if (recoveryPolicy.equals("silent")) {
                transformer.setRecoveryPolicy(Configuration.RECOVER_SILENTLY);
            } else if (recoveryPolicy.equals("recover")) {
                transformer.setRecoveryPolicy(Configuration.RECOVER_WITH_WARNINGS);
            } else {
                transformer.setRecoveryPolicy(Configuration.DO_NOT_RECOVER);
            }
        }
        for (Enumeration e = params.elements(); e.hasMoreElements();) {
            Param p = (Param) e.nextElement();
            if (p.shouldUse()) {
                transformer.setParameter(p.getName(), p.getExpression());
            }
        }
        return transformer;
    }
View Full Code Here

     * if it is referenced).
     * @param exec the Executable
    */

    public XPathContextMajor(Item item, Executable exec) {
        controller = new Controller(exec.getConfiguration(), exec);
        if (item != null) {
            UnfailingIterator iter = SingletonIterator.makeIterator(item);
            iter.next();
            currentIterator = iter;
        }
View Full Code Here

    public XPathContextMajor(Item item, Configuration config) {
        // No longer used internally but retained for backwards compatibility (8.8)
        Executable exec = new Executable(config);
        exec.setHostLanguage(Configuration.JAVA_APPLICATION);
        controller = new Controller(config, exec);
        if (item != null) {
            UnfailingIterator iter = SingletonIterator.makeIterator(item);
            iter.next();
            currentIterator = iter;
        }
View Full Code Here

                } else {
                    return SequenceExtent.makeSequenceExtent(exp.iterate(context));
                }

            case PROCESS:
                Controller controller = context.getController();
                XPathContext c2 = context.newMinorContext();
                c2.setOrigin(exp);
                SequenceOutputter seq = controller.allocateSequenceOutputter(20);
                PipelineConfiguration pipe = controller.makePipelineConfiguration();
                pipe.setHostLanguage(exp.getHostLanguage());
                seq.setPipelineConfiguration(pipe);
                c2.setTemporaryReceiver(seq);
                seq.open();
                exp.process(c2);
View Full Code Here

        final UserFunction fn1 = exp1.getStaticContext().getUserDefinedFunction("f.ns", "t1", 2);
        if (fn1 == null) {
            throw new IllegalStateException("Function f:t1() not found");
        }
        final Controller controller = exp1.newController();
        final Value[] arglist = new Value[2];
        arglist[0] = new Int64Value(10);
        for (int i = 3; i < 10; i++) {
            arglist[1] = new Int64Value(i);
            final ValueRepresentation result = fn1.call(arglist, controller);
View Full Code Here

    */

    public Item evaluateItem(XPathContext context) throws XPathException {
        Item val = argument[0].evaluateItem(context);
        String label = argument[1].evaluateAsString(context).toString();
        Controller controller = context.getController();
        if (controller.isTracing()) {
            notifyListener(label, Value.asValue(val), context);
        } else {
            PrintStream out = controller.getTraceFunctionDestination();
            if (out != null) {
                traceItem(val, label, out);
            }
        }
        return val;
View Full Code Here

    /**
    * Iterate over the results of the function
    */

    public SequenceIterator iterate(XPathContext context) throws XPathException {
        Controller controller = context.getController();
        if (controller.isTracing()) {
            String label = argument[1].evaluateAsString(context).toString();
            Value value = Value.asValue(ExpressionTool.eagerEvaluate(argument[0], context));
            notifyListener(label, value, context);
            return value.iterate();
        } else {
            PrintStream out = controller.getTraceFunctionDestination();
            if (out == null) {
                return argument[0].iterate(context);
            } else {
                return new TracingIterator(argument[0].iterate(context),
                        argument[1].evaluateAsString(context).toString(),
View Full Code Here

TOP

Related Classes of net.sf.saxon.Controller

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.