Package com.xmlcalabash.config

Examples of com.xmlcalabash.config.FoProcessor


        if (runtime.getConfiguration().foProcessor != null) {
            foClasses.add(runtime.getConfiguration().foProcessor);
        }
        foClasses.add("com.xmlcalabash.util.FoFOP");

        FoProcessor provider = null;
        Throwable pexcept = null;
        for (String className : foClasses) {
            if (provider == null) {
                try {
                    provider = (FoProcessor) Class.forName(className).newInstance();
                    provider.initialize(runtime,step,options);
                    break;
                } catch (NoClassDefFoundError ncdfe) {
                    pexcept = ncdfe;
                    provider = null;
                } catch (Exception e) {
                    pexcept = e;
                    provider = null;
                }
            }
        }

        if (provider == null) {
            throw new XProcException(step.getNode(), "Failed to instantiate FO provider", pexcept);
        }

        final String contentType;
        if (getOption(_content_type) != null) {
            contentType = getOption(_content_type).getString();
        } else {
            contentType = "application/octet-stream";
        }

        String base = getOption(_href).getBaseURI().toASCIIString();
        String href = getOption(_href).getString();

        try {
            final FoProcessor processor = provider;
            DataStore store = runtime.getDataStore();
            URI id = store.writeEntry(href, base, contentType, new DataWriter() {
                public void store(OutputStream content) throws IOException {
                    OutputStream out = new BufferedOutputStream(content);
                    try {
                        processor.format(source.read(),out,contentType);
                    } catch (SaxonApiException e) {
                        throw new XProcException(step.getNode(), "Failed to process FO document", e);
                    } finally {
                        out.close();
                    }
View Full Code Here

TOP

Related Classes of com.xmlcalabash.config.FoProcessor

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.