Package com.xmlcalabash.core

Examples of com.xmlcalabash.core.XProcRuntime


    }

    protected Representation getOutput(PipelineConfiguration pipeconfig, String port) {
        XProcConfiguration config = getConfiguration();
        XPipeline pipeline = pipeconfig.pipeline;
        XProcRuntime runtime = pipeconfig.runtime;
        Serialization serial = pipeline.getSerialization(port);

        if (serial == null) {
            // Use the configuration options
            // FIXME: should each of these be considered separately?
View Full Code Here


    protected Representation processMultipartForm(PipelineConfiguration pipeconfig, Representation entity, Variant variant) {
        String id = (String) getRequest().getAttributes().get("id");

        XPipeline xpipeline = pipeconfig.pipeline;
        XProcRuntime runtime = pipeconfig.runtime;

        if (pipeconfig.ran) {
            pipeconfig.reset();
            xpipeline.reset();
        }

        String message = "";

        HashMap<String,String> nameValuePairs = new HashMap<String,String> ();
        HashMap<String,String> nsBindings = new HashMap<String,String> ();

        DiskFileItemFactory factory = new DiskFileItemFactory();
        factory.setSizeThreshold(100240);

        RestletFileUpload upload = new RestletFileUpload(factory);
        List<FileItem> items;
        try {
            items = upload.parseRequest(getRequest());

            File file = null;
            String filename = null;

            for (final Iterator<FileItem> it = items.iterator(); it.hasNext(); ) {
                FileItem fi = it.next();
                String fieldName = fi.getFieldName();
                String name = fi.getName();

                if (name == null) {
                    Matcher matcher = xmlnsRE.matcher(fieldName);
                    if (matcher.matches()) {
                        nsBindings.put(matcher.group(1), new String(fi.get(), "utf-8"));
                    } else {
                        nameValuePairs.put(fieldName, new String(fi.get(), "utf-8"));
                    }
                } else {
                    String port = fieldName;

                    if (pipeconfig.documentCount(port) == 0) {
                        xpipeline.clearInputs(port);
                    }
                    pipeconfig.writeTo(port);

                    try {
                        XdmNode doc = null;
                        MediaType m = new MediaType(fi.getContentType());

                        if (isXml(m)) {
                            doc = runtime.parse(new InputSource(fi.getInputStream()));
                            logger.debug("Posting XML document to " + port + " for " + id);
                        } else {
                            ReadablePipe pipe = null;
                            pipe = new ReadableData(runtime, XProcConstants.c_data, fi.getInputStream(), fi.getContentType());
                            doc = pipe.read();
View Full Code Here

        public IterationPositionCall(XProcExtensionFunctionDefinition def) {
            xdef = def;
        }

        public Sequence call(XPathContext xPathContext, Sequence[] sequences) throws XPathException {
            XProcRuntime runtime = registry.getRuntime(xdef);
            XProcData data = runtime.getXProcData();
            XStep step = data.getStep();
            // FIXME: this can't be the best way to do this...
            // step == null in use-when
            if (step != null && !(step instanceof XCompoundStep)) {
                throw XProcException.dynamicError(23);
            }
            return new Int64Value(runtime.getXProcData().getIterationPosition());
        }
View Full Code Here

        }

        public Sequence call(XPathContext xPathContext, Sequence[] sequences) throws XPathException {
            String baseURI = null;

            XProcRuntime runtime = registry.getRuntime(xdef);
            XStep step = runtime.getXProcData().getStep();
            // FIXME: this can't be the best way to do this...
            // step == null in use-when
            if (step != null && !(step instanceof XCompoundStep)) {
                throw XProcException.dynamicError(23);
            }
View Full Code Here

        }

        public Sequence call(XPathContext xPathContext, Sequence[] sequences) throws XPathException {
            StructuredQName sVarName = null;

            XProcRuntime runtime = registry.getRuntime(xdef);
            XStep step = runtime.getXProcData().getStep();
            // FIXME: this can't be the best way to do this...
            // step == null in use-when
            if (step != null && !(step instanceof XCompoundStep)) {
                throw XProcException.dynamicError(23);
            }
View Full Code Here

        public VersionAvailableCall(XProcExtensionFunctionDefinition def) {
            xdef = def;
        }

        public Sequence call(XPathContext xPathContext, Sequence[] sequences) throws XPathException {
            XProcRuntime runtime = registry.getRuntime(xdef);
            XStep step = runtime.getXProcData().getStep();
            // FIXME: this can't be the best way to do this...
            // step == null in use-when
            if (step != null && !(step instanceof XCompoundStep)) {
                throw XProcException.dynamicError(23);
            }
View Full Code Here

        }

        public Sequence call(XPathContext xPathContext, Sequence[] sequences) throws XPathException {
            StructuredQName stepName = null;

            XProcRuntime runtime = registry.getRuntime(xdef);
            XStep step = runtime.getXProcData().getStep();
            // FIXME: this can't be the best way to do this...
            // step == null in use-when
            if (step != null && !(step instanceof XCompoundStep)) {
                throw XProcException.dynamicError(23);
            }

            try {
                String lexicalQName = sequences[0].head().getStringValue();
                stepName = StructuredQName.fromLexicalQName(
                     lexicalQName,
                     false,
                     false,
                     xPathContext.getConfiguration().getNameChecker(),
                     staticContext.getNamespaceResolver());
            } catch (XPathException e) {
                // FIXME: bad formatting
                throw new XProcException(step.getNode(), "Invalid step name. " + e.getMessage() + "XTDE1390");
            }

            boolean value = false;
            QName stepType = new QName("x", stepName.getURI(), stepName.getLocalPart());

            // FIXME: This doesn't seem terribly efficient...
            while (! (step instanceof XPipeline)) {
                step = step.getParent();
            }

            DeclareStep decl = step.getDeclareStep();

            try {
                decl = decl.getStepDeclaration(stepType);
            } catch (XProcException e) {
                decl = null;
            }

            if (decl != null) {
                if (decl.isAtomic()) {
                    value = runtime.getConfiguration().isStepAvailable(decl.getDeclaredType());
                } else {
                    value = true;
                }
            }
View Full Code Here

            System.err.println(usage);
            System.exit(1);
        }

        XProcConfiguration config = new XProcConfiguration("ee", schemaAware);
        XProcRuntime runtime = new XProcRuntime(config);

        RunTestReport test = new RunTestReport(runtime, new DefaultTestReporter(runtime));
        test.runTests(tests);
    }
View Full Code Here

TOP

Related Classes of com.xmlcalabash.core.XProcRuntime

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.