Package com.xmlcalabash.model

Examples of com.xmlcalabash.model.DeclareStep


        if (!detailed && (inputCount > 1 || outputports.size() > 1)) {
            throw new XProcException(step.getNode(), "You must specify detailed='true' to eval pipelines with multiple inputs or outputs");
        }

        DeclareStep decl = pipeline.getDeclareStep();
        String primaryin = null;
        Iterator<String> portiter = inputports.iterator();
        while (portiter.hasNext()) {
            String port = portiter.next();
            Input input = decl.getInput(port);
            if (!input.getParameterInput() && ((inputports.size() == 1 && !input.getPrimarySet()) || input.getPrimary())) {
                primaryin = port;
            }
        }
View Full Code Here


                tree.addText(port);
                tree.addEndElement();
            }
        } else {
            XPipeline xpipeline = pipeconfig.pipeline;
            DeclareStep pipeline = xpipeline.getDeclareStep();

            for (String port : pipeconfig.inputPorts) {
                tree.addStartElement(pr_input);
                if (port.equals(pipeconfig.definput)) {
                    tree.addAttribute(_primary, "true");
                }
                tree.addAttribute(_documents, "" + pipeconfig.documentCount(port));
                tree.startContent();
                tree.addText(port);
                tree.addEndElement();
            }

            for (QName name : pipeline.getOptions()) {
                tree.addStartElement(pr_option);
                tree.startContent();

                tree.addStartElement(pr_name);
View Full Code Here

                xpipeline.writeTo(pipeconfig.definput, doc);

                HashMap<String, String> nsBindings = bindingsFromForm(getQuery());
                HashMap<String, String> options = convertFormStrings(getQuery());

                DeclareStep pipeline = xpipeline.getDeclareStep();
                for (String fieldName : options.keySet()) {
                    RuntimeValue value = new RuntimeValue(options.get(fieldName));

                    if (fieldName.startsWith("-p")) {
                        fieldName = fieldName.substring(2);

                        String port= null;
                        Matcher matcher = portRE.matcher(fieldName);
                        if (matcher.matches()) {
                            port = matcher.group(1);
                            fieldName = matcher.group(2);
                        }

                        if (port == null) {
                            // Figure out the default parameter port
                            for (String iport : xpipeline.getInputs()) {
                                com.xmlcalabash.model.Input input = pipeline.getInput(iport);
                                if (input.getParameterInput() && input.getPrimary()) {
                                    port = iport;
                                }
                            }
                        }
View Full Code Here

    public PipelineConfiguration(XProcRuntime runtime, XPipeline xpipeline, Calendar expires) {
        this.runtime = runtime;
        this.pipeline = xpipeline;
        this.expires = expires;

        DeclareStep pipeline = xpipeline.getDeclareStep();

        // Figure out the default input port
        for (String port : xpipeline.getInputs()) {
            inputPorts.add(port);
            com.xmlcalabash.model.Input input = pipeline.getInput(port);
            if (!input.getParameterInput() && input.getPrimary()) {
                definput = port;
            }
        }

        // Figure out the default output port
        for (String port : xpipeline.getOutputs()) {
            outputPorts.add(port);
            com.xmlcalabash.model.Output output = pipeline.getOutput(port);
            if (output.getPrimary()) {
                defoutput = port;
            }
        }
    }
View Full Code Here

    public QName getFirstPipelineType() {
        return library.firstStep();
    }

    public XPipeline getPipeline(QName stepName) {
        DeclareStep step = library.getDeclaration(stepName);

        if (step == null) {
            runtime.error(null, library.getNode(), "No step named " + stepName + " in library.", null);
            return null;
        }

        XRootStep root = new XRootStep(runtime);

        if (step.subpipeline().size() == 0) {
            // I need to instantiate an atomic step to replace this declaration in the
            // pipeline I'm about to create.

            Step atomicReplacement = new Step(runtime, step.getNode(),step.getDeclaredType(),step.getName());
            atomicReplacement.setDeclaration(step);

            // TODO: Make sure options and parameters get copied over correctly!

            String wrapper = "XML-CALABASH-GENERATED-WRAPPER-PIPELINE";
            QName ptype = new QName("", "XML-CALABASH-WRAPPER-TYPE");
            // This is an atomic step, manufacture a dummy wrapper pipeline for it.
            DeclareStep pipeline = new DeclareStep(runtime, step.getNode(), wrapper);
            for (Input input : step.inputs()) {
                Input pInput = new Input(runtime, input.getNode());
                pInput.setPort(input.getPort());
                pInput.setPrimary(input.getPrimary());
                pInput.setSequence(input.getSequence());
                pInput.setParameterInput(input.getParameterInput());
                pipeline.addInput(pInput);

                PipeNameBinding pnb = new PipeNameBinding(runtime, input.getNode());
                pnb.setStep(wrapper);
                pnb.setPort(pInput.getPort());
                input.addBinding(pnb);

                atomicReplacement.addInput(input);
            }

            for (Output output : step.outputs()) {
                Output pOutput = new Output(runtime, output.getNode());
                pOutput.setPort(output.getPort());
                pOutput.setPrimary(output.getPrimary());
                pOutput.setSequence(output.getSequence());

                Input pInput = new Input(runtime, output.getNode());
                pInput.setPort("|" + output.getPort());
                pInput.setSequence(output.getSequence());
                pipeline.addInput(pInput);

                PipeNameBinding pnb = new PipeNameBinding(runtime, output.getNode());
                pnb.setStep(step.getName());
                pnb.setPort(output.getPort());
                pInput.addBinding(pnb);

                pipeline.addOutput(pOutput);

                atomicReplacement.addOutput(output);
            }

            pipeline.addStep(atomicReplacement);
            pipeline.setDeclaredType(ptype);
            runtime.declareStep(ptype,pipeline);
            step = pipeline;
            step.setup();
        } else {
            step.setup();
View Full Code Here

        XPipeline xpipeline = pipeconfig.pipeline;

        String port = (String) getRequest().getAttributes().get("port");
        if (port == null) {
            // Figure out the default parameter port
            DeclareStep pipeline = xpipeline.getDeclareStep();
            for (String iport : xpipeline.getInputs()) {
                com.xmlcalabash.model.Input input = pipeline.getInput(iport);
                if (input.getParameterInput() && input.getPrimary()) {
                    port = iport;
                }
            }
        }
View Full Code Here

        // N.B. At this time, there are no compound steps that accept parameters or options,
        // so the order in which we calculate them doesn't matter. That will change if/when
        // there are such compound steps.

        // Calculate all the options
        DeclareStep decl = step.getDeclaration();
        inScopeOptions = parent.getInScopeOptions();
        for (QName name : step.getOptions()) {
            Option option = step.getOption(name);
            RuntimeValue value = computeValue(option);

            Option optionDecl = decl.getOption(name);
            String typeName = optionDecl.getType();
            XdmNode declNode = optionDecl.getNode();
            if (typeName != null && declNode != null) {
                if (typeName.contains("|")) {
                    TypeUtils.checkLiteral(value.getString(), typeName);
View Full Code Here

                    message += "Posted input to port '" + port + "'\n";
                }
            }


            DeclareStep pipeline = xpipeline.getDeclareStep();
            for (String fieldName : nameValuePairs.keySet()) {
                RuntimeValue value = new RuntimeValue(nameValuePairs.get(fieldName));

                if (fieldName.startsWith("-p")) {
                    fieldName = fieldName.substring(2);

                    String port= null;
                    Matcher matcher = portRE.matcher(fieldName);
                    if (matcher.matches()) {
                        port = matcher.group(1);
                        fieldName = matcher.group(2);
                    }

                    if (port == null) {
                        // Figure out the default parameter port
                        for (String iport : xpipeline.getInputs()) {
                            com.xmlcalabash.model.Input input = pipeline.getInput(iport);
                            if (input.getParameterInput() && input.getPrimary()) {
                                port = iport;
                            }
                        }
                    }
View Full Code Here

        if (errorCode != null) {
            throw new XProcException(errorCode, errorMessage);
        }

        XRootStep root = new XRootStep(this);
        DeclareStep decl = pipeline.getDeclaration();
        decl.setup();

        if (errorCode != null) {
            throw new XProcException(errorCode, errorNode, errorMessage);
        }
View Full Code Here

        if (errorCode != null) {
            throw new XProcException(errorCode, errorMessage);
        }

        XRootStep root = new XRootStep(this);
        DeclareStep decl = pipeline.getDeclaration();
        decl.setup();

        if (errorCode != null) {
            throw new XProcException(errorCode, errorMessage);
        }
View Full Code Here

TOP

Related Classes of com.xmlcalabash.model.DeclareStep

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.