Examples of RuntimeValue


Examples of com.xmlcalabash.model.RuntimeValue

        String prefix = "temp";
        String suffix = ".xml";
        boolean delete = false;

        RuntimeValue value = getOption(_prefix);
        if (value != null) {
            prefix = value.getString();
        }
        value = getOption(_suffix);
        if (value != null) {
            suffix = value.getString();
        }
        delete = getOption(_delete_on_exit, false);

        RuntimeValue href = getOption(_href);
        URI uri = href.getBaseURI().resolve(href.getString());
        File file;
        if (!"file".equals(uri.getScheme())) {
            throw new XProcException(step.getNode(), "Only file: scheme URIs are supported by the tempfile step.");
        } else {
            file = new File(uri.getPath());
View Full Code Here

Examples of com.xmlcalabash.model.RuntimeValue

        if (runtime.getSafeMode()) {
            throw XProcException.dynamicError(21);
        }

        RuntimeValue href = getOption(_href);

        final TreeWriter tree = new TreeWriter(runtime);
        tree.startDocument(step.getNode().getBaseURI());
        tree.addStartElement(XProcConstants.c_result);
        tree.startContent();

        try {
            DataStore store = runtime.getDataStore();
            String base = href.getBaseURI().toASCIIString();
            try {
                store.infoEntry(href.getString(), base, "*/*", new DataInfo() {
                    public void list(URI id, String media, long lastModified)
                            throws IOException {
                        // file already exists
                        tree.addText(id.toASCIIString());
                    }
                });
            } catch (FileNotFoundException e) {
                URI uri = store.writeEntry(href.getString(), base, "text/plain", new DataWriter() {
                    public void store(OutputStream content) throws IOException {
                        // empty file
                    }
                });
                tree.addText(uri.toASCIIString());
View Full Code Here

Examples of com.xmlcalabash.model.RuntimeValue

        boolean failOnError = getOption(_fail_on_error, true);
        final int maxCount = getOption(_count, 10);
        final int negMaxCount = -maxCount;

        RuntimeValue href = getOption(_href);

        final TreeWriter tree = new TreeWriter(runtime);
        tree.startDocument(step.getNode().getBaseURI());
        tree.addStartElement(XProcConstants.c_result);
        tree.startContent();

        try {
            DataStore store = runtime.getDataStore();
            store.readEntry(href.getString(), href.getBaseURI().toASCIIString(), "text/*, */*", null, new DataReader() {
                public void load(URI id, String media, InputStream content, long len)
                        throws IOException {
                    Reader rdr = new InputStreamReader(content);
                    BufferedReader brdr = new BufferedReader(rdr);
                    try {
                        String line = null;
                        int count = 0;

                        if (maxCount >= 0) {
                            line = brdr.readLine();
                            while (line != null && count < maxCount) {
                                tree.addStartElement(c_line);
                                tree.startContent();
                                tree.addText(line);
                                tree.addEndElement();
                                tree.addText("\n");
                                count++;
                                line = brdr.readLine();
                            }
                        } else {
                            line = "not null";
                            while (line != null && count < negMaxCount) {
                                count++;
                                line = brdr.readLine();
                            }

                            line = brdr.readLine();
                            while (line != null) {
                                tree.addStartElement(c_line);
                                tree.startContent();
                                tree.addText(line);
                                tree.addEndElement();
                                tree.addText("\n");
                                line = brdr.readLine();
                            }
                        }
                    } finally {
                        brdr.close();
                        // BufferedReader.close() also closes the underlying
                        // reader, so this second call is unnecessary.
                        // rdr.close();
                    }
                }
            });
        } catch (FileNotFoundException fnfe) {
            URI uri = href.getBaseURI().resolve(href.getString());
            throw new XProcException(step.getNode(), "Cannot read: file does not exist: " + uri.toASCIIString());
        } catch (IOException ioe) {
            throw new XProcException(ioe);
        }

View Full Code Here

Examples of com.xmlcalabash.model.RuntimeValue

                sequencePosition++;
                runtime.getXProcData().setIterationPosition(sequencePosition);

                for (Variable var : step.getVariables()) {
                    RuntimeValue value = computeValue(var);
                    inScopeOptions.put(var.getName(), value);
                }

                // 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 variables
                inScopeOptions = parent.getInScopeOptions();
                for (Variable var : step.getVariables()) {
                    RuntimeValue value = computeValue(var);
                    inScopeOptions.put(var.getName(), value);
                }

                for (XStep step : subpipeline) {
                    step.run();
View Full Code Here

Examples of com.xmlcalabash.model.RuntimeValue

                        sequencePosition++;
                        runtime.getXProcData().setIterationPosition(sequencePosition);

                        for (Variable var : step.getVariables()) {
                            RuntimeValue value = computeValue(var);
                            inScopeOptions.put(var.getName(), value);
                        }

                        // 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 variables
                        inScopeOptions = parent.getInScopeOptions();
                        for (Variable var : step.getVariables()) {
                            RuntimeValue value = computeValue(var);
                            inScopeOptions.put(var.getName(), value);
                        }

                        for (XStep step : subpipeline) {
                            step.run();
View Full Code Here

Examples of com.xmlcalabash.model.RuntimeValue

            throw new XProcException(e);
        }

        String message = "Parameter added: " + qname.toString();

        RuntimeValue value = new RuntimeValue(null, nodes, null, null);
        xpipeline.setParameter(port, qname, value);
        pipeconfig.setGVParameter(qname);

        return okResponse(message, variant.getMediaType(), Status.SUCCESS_ACCEPTED);
    }
View Full Code Here

Examples of com.xmlcalabash.model.RuntimeValue

    private XdmNode expandXIncludes(XdmNode doc) {
        logger.trace(MessageFormatter.nodeMessage(doc, "Starting expandXIncludes"));
        ProcessMatch matcher = new ProcessMatch(runtime, this);
        matcherStack.push(matcher);
        matcher.match(doc, new RuntimeValue("/|*", step.getNode()));
        XdmNode result = matcher.getResult();
        matcher = matcherStack.pop();
        return result;
    }
View Full Code Here

Examples of com.xmlcalabash.model.RuntimeValue

        return getParent() != null && getParent().hasInScopeVariableBinding(name);
    }

    public boolean hasInScopeVariableValue(QName name) {
        if (inScopeOptions.containsKey(name)) {
            RuntimeValue v = getOption(name);
            return v.initialized();
        }

        return getParent() != null && getParent().hasInScopeVariableBinding(name);
    }
View Full Code Here

Examples of com.xmlcalabash.model.RuntimeValue

            xinclude = node;
        }

        public XdmNode fixup(XdmNode node) {
            matcher = new ProcessMatch(runtime, this);
            matcher.match(node, new RuntimeValue("*", step.getNode()));
            XdmNode fixed = matcher.getResult();
            return fixed;
        }
View Full Code Here

Examples of com.xmlcalabash.model.RuntimeValue

        // 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);
                } else {
                    QName type = new QName(typeName, declNode);
                    TypeUtils.checkType(runtime, value.getString(),type,option.getNode());
                }
            }

            xstep.setOption(name, value);
            inScopeOptions.put(name, value);
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.