aboutsummaryrefslogtreecommitdiffstats
path: root/src/org
diff options
context:
space:
mode:
authorarved <arved@unknown>2001-02-21 01:11:44 +0000
committerarved <arved@unknown>2001-02-21 01:11:44 +0000
commitd8fca83a3e423197b09e046b5fef382d5d5f7017 (patch)
treeb55d9e257c912adb9e030d58331eb1b76fdf0088 /src/org
parenta6869df507ecab2dedf6a9264f09349d00015d2f (diff)
downloadxmlgraphics-fop-d8fca83a3e423197b09e046b5fef382d5d5f7017.tar.gz
xmlgraphics-fop-d8fca83a3e423197b09e046b5fef382d5d5f7017.zip
No longer required
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194081 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/org')
-rw-r--r--src/org/apache/fop/apps/AWTCommandLine.java243
-rw-r--r--src/org/apache/fop/apps/CommandLine.java272
-rw-r--r--src/org/apache/fop/apps/MIFCommandLine.java274
-rwxr-xr-xsrc/org/apache/fop/apps/PrintCommandLine.java199
-rw-r--r--src/org/apache/fop/apps/XTCommandLine.java185
-rw-r--r--src/org/apache/fop/apps/XalanCommandLine.java344
6 files changed, 0 insertions, 1517 deletions
diff --git a/src/org/apache/fop/apps/AWTCommandLine.java b/src/org/apache/fop/apps/AWTCommandLine.java
deleted file mode 100644
index c82023cb9..000000000
--- a/src/org/apache/fop/apps/AWTCommandLine.java
+++ /dev/null
@@ -1,243 +0,0 @@
-
-package org.apache.fop.apps;
-/*
- originally contributed by
- Juergen Verwohlt: Juergen.Verwohlt@jCatalog.com,
- Rainer Steinkuhle: Rainer.Steinkuhle@jCatalog.com,
- Stanislav Gorkhover: Stanislav.Gorkhover@jCatalog.com
- */
-import org.apache.fop.messaging.MessageHandler;
-import org.apache.fop.viewer.*;
-import org.apache.fop.render.awt.*;
-
-
-import javax.swing.UIManager;
-import java.awt.*;
-
-// SAX
-import org.xml.sax.XMLReader;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-
-
-// Java
-import java.io.FileReader;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.PrintWriter;
-import java.io.IOException;
-import java.io.FileNotFoundException;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.*;
-
-
-
-/**
- * initialize AWT previewer
- */
-
-public class AWTCommandLine {
-
-
- public static String TRANSLATION_PATH = "/org/apache/fop/viewer/resources/";
-
-
- private Translator resource;
-
-
-
- public AWTCommandLine(String srcFile, String language) {
-
- if (language == null)
- language = System.getProperty("user.language");
-
- resource = getResourceBundle(TRANSLATION_PATH + "resources." +
- language);
-
- UserMessage.setTranslator(
- getResourceBundle(TRANSLATION_PATH + "messages." +
- language));
-
- resource.setMissingEmphasized(false);
- AWTRenderer renderer = new AWTRenderer(resource);
- PreviewDialog frame = createPreviewDialog(renderer, resource);
- renderer.setProgressListener(frame);
- renderer.setComponent(frame);
- MessageHandler.setOutputMethod(MessageHandler.EVENT);
- MessageHandler.addListener(frame);
-
- //init parser
- frame.progress(resource.getString("Init parser") + " ...");
- XMLReader parser = createParser();
-
- if (parser == null) {
- MessageHandler.errorln("ERROR: Unable to create SAX parser");
- System.exit(1);
- }
-
- // setting the necessary parser features
- try {
- parser.setFeature("http://xml.org/sax/features/namespace-prefixes",
- true);
- } catch (SAXException e) {
- MessageHandler.errorln("Error in setting up parser feature namespace-prefixes");
- MessageHandler.errorln("You need a parser which supports SAX version 2");
- System.exit(1);
- }
-
- try {
- Driver driver = new Driver();
- driver.setRenderer(renderer);
-
- // init mappings: time
- frame.progress(resource.getString("Init mappings") + " ...");
-
- driver.addElementMapping("org.apache.fop.fo.StandardElementMapping");
- driver.addElementMapping("org.apache.fop.svg.SVGElementMapping");
- driver.addPropertyList("org.apache.fop.fo.StandardPropertyListMapping");
- driver.addPropertyList("org.apache.fop.svg.SVGPropertyListMapping");
-
- // build FO tree: time
- frame.progress(resource.getString("Build FO tree") + " ...");
- driver.buildFOTree(parser, fileInputSource(srcFile));
-
- // layout FO tree: time
- frame.progress(resource.getString("Layout FO tree") + " ...");
- driver.format();
-
- // render: time
- frame.progress(resource.getString("Render") + " ...");
- driver.render();
-
- frame.progress(resource.getString("Show"));
- frame.showPage();
-
- } catch (Exception e) {
- MessageHandler.errorln("FATAL ERROR: " + e.getMessage());
- e.printStackTrace();
- System.exit(1);
- }
- }
-
-
- static XMLReader createParser() {
- String parserClassName = System.getProperty("org.xml.sax.parser");
- if (parserClassName == null) {
- parserClassName = "org.apache.xerces.parsers.SAXParser";
- }
- MessageHandler.logln("using SAX parser " + parserClassName);
-
- try {
- return (XMLReader) Class.forName(
- parserClassName).newInstance();
- } catch (ClassNotFoundException e) {
- MessageHandler.errorln("Could not find " + parserClassName);
- }
- catch (InstantiationException e) {
- MessageHandler.errorln("Could not instantiate " +
- parserClassName);
- }
- catch (IllegalAccessException e) {
- MessageHandler.errorln("Could not access " + parserClassName);
- }
- catch (ClassCastException e) {
- MessageHandler.errorln(parserClassName + " is not a SAX driver");
- }
- return null;
- }
-
-
-
- protected PreviewDialog createPreviewDialog(AWTRenderer renderer,
- Translator res) {
- PreviewDialog frame = new PreviewDialog(renderer, res);
- frame.validate();
-
- // center window
- Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
- Dimension frameSize = frame.getSize();
- if (frameSize.height > screenSize.height)
- frameSize.height = screenSize.height;
- if (frameSize.width > screenSize.width)
- frameSize.width = screenSize.width;
- frame.setLocation((screenSize.width - frameSize.width) / 2,
- (screenSize.height - frameSize.height) / 2);
- frame.setVisible(true);
- return frame;
- }
-
-
-
- /**
- * create an InputSource from a file name
- *
- * @param filename the name of the file
- * @return the InputSource created
- */
- protected static InputSource fileInputSource(String filename) {
- /* this code adapted from James Clark's in XT */
- File file = new File(filename);
- String path = file.getAbsolutePath();
- String fSep = System.getProperty("file.separator");
- if (fSep != null && fSep.length() == 1)
- path = path.replace(fSep.charAt(0), '/');
- if (path.length() > 0 && path.charAt(0) != '/')
- path = '/' + path;
- try {
- return new InputSource(new URL("file", null, path).toString());
- } catch (java.net.MalformedURLException e) {
- throw new Error("unexpected MalformedURLException");
- }
- }
-
-
- private SecureResourceBundle getResourceBundle(String path) {
- InputStream in = null;
-
- try {
- URL url = getClass().getResource(path);
- in = url.openStream();
- } catch (Exception ex) {
- MessageHandler.logln("Can't find URL to: <" + path + "> " +
- ex.getMessage());
- }
- return new SecureResourceBundle(in);
- }
-
-
- /* main
- */
- public static void main(String[] args) {
- try {
- UIManager.setLookAndFeel(
- new javax.swing.plaf.metal.MetalLookAndFeel());
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- String srcPath = null;
- String language = null;
- String imageDir = null;
-
- MessageHandler.errorln(Version.getVersion());
- if (args.length < 1 || args.length > 3) {
- MessageHandler.errorln("usage: java AWTCommandLine " + "formatting-object-file [language] ");
- System.exit(1);
- }
-
- srcPath = args[0];
- if (args.length > 1) {
- language = args[1];
- }
-
- new AWTCommandLine(srcPath, language);
-
- } // main
-} // AWTCommandLine
-
-
-
diff --git a/src/org/apache/fop/apps/CommandLine.java b/src/org/apache/fop/apps/CommandLine.java
deleted file mode 100644
index f26ff7b9b..000000000
--- a/src/org/apache/fop/apps/CommandLine.java
+++ /dev/null
@@ -1,272 +0,0 @@
-/*-- $Id$ --
-
- ============================================================================
- The Apache Software License, Version 1.1
- ============================================================================
-
- Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modifica-
- tion, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- 3. The end-user documentation included with the redistribution, if any, must
- include the following acknowledgment: "This product includes software
- developed by the Apache Software Foundation (http://www.apache.org/)."
- Alternately, this acknowledgment may appear in the software itself, if
- and wherever such third-party acknowledgments normally appear.
-
- 4. The names "Fop" and "Apache Software Foundation" must not be used to
- endorse or promote products derived from this software without prior
- written permission. For written permission, please contact
- apache@apache.org.
-
- 5. Products derived from this software may not be called "Apache", nor may
- "Apache" appear in their name, without prior written permission of the
- Apache Software Foundation.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- This software consists of voluntary contributions made by many individuals
- on behalf of the Apache Software Foundation and was originally created by
- James Tauber <jtauber@jtauber.com>. For more information on the Apache
- Software Foundation, please see <http://www.apache.org/>.
-
- */
-
-
-package org.apache.fop.apps;
-
-// SAX
-import org.xml.sax.XMLReader;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-// Java
-import java.io.*;
-import java.net.URL;
-
-
-// FOP
-import org.apache.fop.messaging.MessageHandler;
-import org.apache.fop.configuration.Configuration;
-
-/**
- * mainline class.
- *
- * Gets input and output filenames from the command line.
- * Creates a SAX Parser (defaulting to Xerces).
- *
- */
-public class CommandLine {
-
- private String foFile = null;
- private String pdfFile = null;
- private String userConfigFile = null;
- private String baseDir = null;
- private boolean dumpConfiguration = false;
-
- /** show a full dump on error */
- private static boolean errorDump = false;
-
- public CommandLine(String[] args) {
- for (int i = 0; i < args.length; i++) {
- if (args[i].equals("-d") || args[i].equals("--full-error-dump")) {
- errorDump = true;
- } else if (args[i].equals("-x")) {
- dumpConfiguration = true;
- } else if ((args[i].charAt(0) == '-') &&
- (args[i].charAt(1) == 'c')) {
- userConfigFile = args[i].substring(2);
- } else if (args[i].charAt(0) == '-') {
- printUsage(args[i]);
- } else if (foFile == null) {
- foFile = args[i];
- } else if (pdfFile == null) {
- pdfFile = args[i];
- } else {
- printUsage(args[i]);
- }
- }
- if (foFile == null || pdfFile == null) {
- printUsage(null);
- }
- }
-
- public void printUsage(String arg) {
- if (arg != null) {
- MessageHandler.errorln("Unknown argument: '"+arg + "'");
- }
- MessageHandler.errorln("Usage: java [-d] [-x]" +
- "[-cMyConfigFile] \n" +
- " org.apache.fop.apps.CommandLine " + "formatting-object-file pdf-file");
- MessageHandler.errorln("Options:\n" + " -d or --full-error-dump Show stack traces upon error");
- MessageHandler.errorln(" -x dump configuration information");
- MessageHandler.errorln(" -cMyConfigFile use configuration file MyConfigFile");
-
- System.exit(1);
- }
-
- public void run() {
- Driver driver = new Driver();
- if (errorDump) {
- driver.setErrorDump(true);
- }
- if (userConfigFile != null) {
- driver.loadUserconfiguration(userConfigFile);
- }
- driver.setBaseDir(foFile);
-
- if (dumpConfiguration) {
- Configuration.dumpConfiguration();
- System.exit(0);
- }
-
- String version = Version.getVersion();
- MessageHandler.logln(version);
-
- XMLReader parser = createParser();
-
- if (parser == null) {
- MessageHandler.errorln("ERROR: Unable to create SAX parser");
- System.exit(1);
- }
-
- // setting the parser features
- try {
- parser.setFeature("http://xml.org/sax/features/namespace-prefixes",
- true);
- } catch (SAXException e) {
- MessageHandler.errorln("Error in setting up parser feature namespace-prefixes");
- MessageHandler.errorln("You need a parser which supports SAX version 2");
- if (errorDump) {
- e.printStackTrace();
- }
- System.exit(1);
- }
-
- try {
- driver.setRenderer("org.apache.fop.render.pdf.PDFRenderer",
- Version.getVersion());
- driver.addElementMapping("org.apache.fop.fo.StandardElementMapping");
- driver.addElementMapping("org.apache.fop.svg.SVGElementMapping");
- driver.addElementMapping("org.apache.fop.extensions.ExtensionElementMapping");
- driver.addPropertyList("org.apache.fop.fo.StandardPropertyListMapping");
- driver.addPropertyList("org.apache.fop.svg.SVGPropertyListMapping");
- driver.addPropertyList("org.apache.fop.extensions.ExtensionPropertyListMapping");
- driver.buildFOTree(parser, fileInputSource(foFile));
- driver.format();
- driver.setOutputStream(new FileOutputStream(pdfFile));
- driver.render();
- } catch (Exception e) {
- MessageHandler.errorln("FATAL ERROR: " + e.getMessage());
- if (errorDump) {
- e.printStackTrace();
- }
- System.exit(1);
- }
- }
-
-
- /**
- * creates a SAX parser, using the value of org.xml.sax.parser
- * defaulting to org.apache.xerces.parsers.SAXParser
- *
- * @return the created SAX parser
- */
- static XMLReader createParser() {
- String parserClassName = System.getProperty("org.xml.sax.parser");
- if (parserClassName == null) {
- parserClassName = "org.apache.xerces.parsers.SAXParser";
- }
- org.apache.fop.messaging.MessageHandler.logln(
- "using SAX parser " + parserClassName);
-
- try {
- return (XMLReader) Class.forName(
- parserClassName).newInstance();
- } catch (ClassNotFoundException e) {
- org.apache.fop.messaging.MessageHandler.errorln(
- "Could not find " + parserClassName);
- if (errorDump) {
- e.printStackTrace();
- }
- }
- catch (InstantiationException e) {
- org.apache.fop.messaging.MessageHandler.errorln(
- "Could not instantiate " + parserClassName);
- if (errorDump) {
- e.printStackTrace();
- }
- }
- catch (IllegalAccessException e) {
- org.apache.fop.messaging.MessageHandler.errorln(
- "Could not access " + parserClassName);
- if (errorDump) {
- e.printStackTrace();
- }
- }
- catch (ClassCastException e) {
- org.apache.fop.messaging.MessageHandler.errorln(
- parserClassName + " is not a SAX driver");
- if (errorDump) {
- e.printStackTrace();
- }
- }
- return null;
- }
-
- /**
- * create an InputSource from a file name
- *
- * @param filename the name of the file
- * @return the InputSource created
- */
- public static InputSource fileInputSource(String filename) {
-
- /* this code adapted from James Clark's in XT */
- File file = new File(filename);
- String path = file.getAbsolutePath();
- String fSep = System.getProperty("file.separator");
- if (fSep != null && fSep.length() == 1)
- path = path.replace(fSep.charAt(0), '/');
- if (path.length() > 0 && path.charAt(0) != '/')
- path = '/' + path;
- try {
- return new InputSource(new URL("file", null, path).toString());
- } catch (java.net.MalformedURLException e) {
- throw new Error("unexpected MalformedURLException");
- }
- }
-
- /**
- * mainline method
- *
- * first command line argument is input file
- * second command line argument is output file
- *
- * @param command line arguments
- */
- public static void main(String[] args) {
- CommandLine cmdLine = new CommandLine(args);
- cmdLine.run();
-
- }
-
-}
diff --git a/src/org/apache/fop/apps/MIFCommandLine.java b/src/org/apache/fop/apps/MIFCommandLine.java
deleted file mode 100644
index fb2509b58..000000000
--- a/src/org/apache/fop/apps/MIFCommandLine.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/*-- $Id$ --
-
- ============================================================================
- The Apache Software License, Version 1.1
- ============================================================================
-
- Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modifica-
- tion, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- 3. The end-user documentation included with the redistribution, if any, must
- include the following acknowledgment: "This product includes software
- developed by the Apache Software Foundation (http://www.apache.org/)."
- Alternately, this acknowledgment may appear in the software itself, if
- and wherever such third-party acknowledgments normally appear.
-
- 4. The names "Fop" and "Apache Software Foundation" must not be used to
- endorse or promote products derived from this software without prior
- written permission. For written permission, please contact
- apache@apache.org.
-
- 5. Products derived from this software may not be called "Apache", nor may
- "Apache" appear in their name, without prior written permission of the
- Apache Software Foundation.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- This software consists of voluntary contributions made by many individuals
- on behalf of the Apache Software Foundation and was originally created by
- James Tauber <jtauber@jtauber.com>. For more information on the Apache
- Software Foundation, please see <http://www.apache.org/>.
-
- */
-
-
-//author : seshadrig
-
-
-
-package org.apache.fop.apps;
-
-// SAX
-import org.xml.sax.XMLReader;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-// Java
-import java.io.*;
-import java.net.URL;
-
-
-// FOP
-import org.apache.fop.messaging.MessageHandler;
-import org.apache.fop.configuration.Configuration;
-
-/**
- * mainline class.
- *
- * Gets input and output filenames from the command line.
- * Creates a SAX Parser (defaulting to Xerces).
- *
- */
-public class MIFCommandLine {
-
- private String foFile = null;
- private String mifFile = null;
- private String userConfigFile = null;
- private String baseDir = null;
- private boolean dumpConfiguration = false;
-
- /** show a full dump on error */
- private static boolean errorDump = false;
-
- public MIFCommandLine(String[] args) {
- for (int i = 0; i < args.length; i++) {
- if (args[i].equals("-d") || args[i].equals("--full-error-dump")) {
- errorDump = true;
- } else if (args[i].equals("-x")) {
- dumpConfiguration = true;
- } else if ((args[i].charAt(0) == '-') &&
- (args[i].charAt(1) == 'c')) {
- userConfigFile = args[i].substring(2);
- } else if (args[i].charAt(0) == '-') {
- printUsage(args[i]);
- } else if (foFile == null) {
- foFile = args[i];
- } else if (mifFile == null) {
- mifFile = args[i];
- } else {
- printUsage(args[i]);
- }
- }
- if (foFile == null || mifFile == null) {
- printUsage(null);
- }
- }
-
- public void printUsage(String arg) {
- if (arg != null) {
- MessageHandler.errorln("Unknown argument: '"+arg + "'");
- }
- MessageHandler.errorln("Usage: java [-d] [-x]" +
- "[-cMyConfigFile] \n" +
- " org.apache.fop.apps.CommandLine " + "formatting-object-file pdf-file");
- MessageHandler.errorln("Options:\n" + " -d or --full-error-dump Show stack traces upon error");
- MessageHandler.errorln(" -x dump configuration information");
- MessageHandler.errorln(" -cMyConfigFile use configuration file MyConfigFile");
-
- System.exit(1);
- }
-
- public void run() {
- Driver driver = new Driver();
- if (errorDump) {
- driver.setErrorDump(true);
- }
- if (userConfigFile != null) {
- driver.loadUserconfiguration(userConfigFile);
- }
- driver.setBaseDir(foFile);
-
- if (dumpConfiguration) {
- Configuration.dumpConfiguration();
- System.exit(0);
- }
-
- String version = Version.getVersion();
- MessageHandler.logln(version);
-
- XMLReader parser = createParser();
-
- if (parser == null) {
- MessageHandler.errorln("ERROR: Unable to create SAX parser");
- System.exit(1);
- }
-
- // setting the parser features
- try {
- parser.setFeature("http://xml.org/sax/features/namespace-prefixes",
- true);
- } catch (SAXException e) {
- MessageHandler.errorln("Error in setting up parser feature namespace-prefixes");
- MessageHandler.errorln("You need a parser which supports SAX version 2");
- if (errorDump) {
- e.printStackTrace();
- }
- System.exit(1);
- }
-
- try {
- driver.setRenderer("org.apache.fop.render.mif.MIFRenderer",
- Version.getVersion());
- driver.addElementMapping("org.apache.fop.fo.StandardElementMapping");
- driver.addElementMapping("org.apache.fop.svg.SVGElementMapping");
- driver.addPropertyList("org.apache.fop.fo.StandardPropertyListMapping");
- driver.addPropertyList("org.apache.fop.svg.SVGPropertyListMapping");
- driver.buildFOTree(parser, fileInputSource(foFile));
- driver.format();
- driver.setOutputStream(new FileOutputStream(mifFile));
- driver.render();
- } catch (Exception e) {
- MessageHandler.errorln("FATAL ERROR: " + e.getMessage());
- if (errorDump) {
- e.printStackTrace();
- }
- System.exit(1);
- }
- }
-
-
- /**
- * creates a SAX parser, using the value of org.xml.sax.parser
- * defaulting to org.apache.xerces.parsers.SAXParser
- *
- * @return the created SAX parser
- */
- static XMLReader createParser() {
- String parserClassName = System.getProperty("org.xml.sax.parser");
- if (parserClassName == null) {
- parserClassName = "org.apache.xerces.parsers.SAXParser";
- }
- org.apache.fop.messaging.MessageHandler.logln(
- "using SAX parser " + parserClassName);
-
- try {
- return (XMLReader) Class.forName(
- parserClassName).newInstance();
- } catch (ClassNotFoundException e) {
- org.apache.fop.messaging.MessageHandler.errorln(
- "Could not find " + parserClassName);
- if (errorDump) {
- e.printStackTrace();
- }
- }
- catch (InstantiationException e) {
- org.apache.fop.messaging.MessageHandler.errorln(
- "Could not instantiate " + parserClassName);
- if (errorDump) {
- e.printStackTrace();
- }
- }
- catch (IllegalAccessException e) {
- org.apache.fop.messaging.MessageHandler.errorln(
- "Could not access " + parserClassName);
- if (errorDump) {
- e.printStackTrace();
- }
- }
- catch (ClassCastException e) {
- org.apache.fop.messaging.MessageHandler.errorln(
- parserClassName + " is not a SAX driver");
- if (errorDump) {
- e.printStackTrace();
- }
- }
- return null;
- }
-
- /**
- * create an InputSource from a file name
- *
- * @param filename the name of the file
- * @return the InputSource created
- */
- public static InputSource fileInputSource(String filename) {
-
- /* this code adapted from James Clark's in XT */
- File file = new File(filename);
- String path = file.getAbsolutePath();
- String fSep = System.getProperty("file.separator");
- if (fSep != null && fSep.length() == 1)
- path = path.replace(fSep.charAt(0), '/');
- if (path.length() > 0 && path.charAt(0) != '/')
- path = '/' + path;
- try {
- return new InputSource(new URL("file", null, path).toString());
- } catch (java.net.MalformedURLException e) {
- throw new Error("unexpected MalformedURLException");
- }
- }
-
- /**
- * mainline method
- *
- * first command line argument is input file
- * second command line argument is output file
- *
- * @param command line arguments
- */
- public static void main(String[] args) {
- MIFCommandLine mifcmdLine = new MIFCommandLine(args);
- mifcmdLine.run();
-
- }
-
-}
diff --git a/src/org/apache/fop/apps/PrintCommandLine.java b/src/org/apache/fop/apps/PrintCommandLine.java
deleted file mode 100755
index 199568d13..000000000
--- a/src/org/apache/fop/apps/PrintCommandLine.java
+++ /dev/null
@@ -1,199 +0,0 @@
-package org.apache.fop.apps;
-
-/*
- originally contributed by
- Stanislav Gorkhover: stanislav.gorkhover@jcatalog.com
- jCatalog Software AG
- */
-
-
-import org.xml.sax.XMLReader;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-import java.awt.Graphics;
-import java.awt.print.*;
-import java.io.OutputStream;
-import java.io.IOException;
-import java.util.Vector;
-
-import org.apache.fop.render.awt.AWTRenderer;
-import org.apache.fop.layout.AreaTree;
-import org.apache.fop.layout.Page;
-import org.apache.fop.messaging.MessageHandler;
-
-
-/**
- * This class prints a xsl-fo dokument without interaction.
- * At the moment java has not the possibility to configure the printer and it's
- * options without interaction (30.03.2000).
- * This class allows to print a set of pages (from-to), even/odd pages and many copies.
- * - Print from page xxx: property name - start, value int
- * - Print to page xxx: property name - end, value int
- * - Print even/odd pages: property name - even, value boolean
- * - Print xxx copies: property name - copies, value int
- *
- */
-public class PrintCommandLine extends CommandLine {
-
- public PrintCommandLine(String args []) {
- super (args);
- }
-
- public static void main(String[] args) {
- String version = Version.getVersion();
- MessageHandler.errorln(version);
-
- if (args.length != 1) {
- MessageHandler.errorln("usage: java [-Dstart=i] [-Dend=i]"
- + " [-Dcopies=i] [-Deven=true|false]"
- + " org.apache.fop.apps.PrintCommandLine formatting-object-file");
- System.exit(1);
- }
-
- XMLReader parser = createParser();
-
- if (parser == null) {
- MessageHandler.errorln("ERROR: Unable to create SAX parser");
- System.exit(1);
- }
-
- // setting the necessary parser features
- try {
- parser.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
- } catch (SAXException e) {
- MessageHandler.errorln("Error in setting up parser feature namespace-prefixes");
- MessageHandler.errorln("You need a parser which supports SAX version 2");
- }
-
- PrintRenderer renderer = new PrintRenderer();
- try {
- Driver driver = new Driver();
-
- driver.setRenderer(renderer);
- driver.addElementMapping("org.apache.fop.fo.StandardElementMapping");
- driver.addElementMapping("org.apache.fop.svg.SVGElementMapping");
- driver.addPropertyList("org.apache.fop.fo.StandardPropertyListMapping");
- driver.addPropertyList("org.apache.fop.svg.SVGPropertyListMapping");
- driver.buildFOTree(parser, fileInputSource(args[0]));
- driver.format();
- driver.render();
- } catch (Exception e) {
- MessageHandler.errorln("FATAL ERROR: " + e.getMessage());
- System.exit(1);
- }
-
- int copies = PrintRenderer.getIntProperty("copies", 1);
- renderer.setCopies(copies);
-
- PrinterJob pj = PrinterJob.getPrinterJob();
- pj.setPageable(renderer);
-
- pj.setCopies(copies);
- try {
- pj.print();
- } catch(PrinterException pe) {
- pe.printStackTrace();
- }
- }
-
-
- static class PrintRenderer extends AWTRenderer {
-
- static int EVEN_AND_ALL = 0;
- static int EVEN = 1;
- static int ODD = 2;
-
- int startNumber;
- int endNumber;
- int mode = EVEN_AND_ALL;
- int copies = 1;
-
- PrintRenderer() {
- super(null);
-
- startNumber = getIntProperty("start", 1) - 1;
- endNumber = getIntProperty("end", -1);
-
- mode = EVEN_AND_ALL;
- String str = System.getProperty("even");
- if (str != null) {
- try {
- mode = Boolean.valueOf(str).booleanValue() ? EVEN : ODD;
- } catch (Exception e) {
- }
- }
-
- }
-
-
- static int getIntProperty(String name, int def) {
- String propValue = System.getProperty(name);
- if (propValue != null) {
- try {
- return Integer.parseInt(propValue);
- } catch(Exception e) {
- return def;
- }
- }
- else {
- return def;
- }
- }
-
- public void render(AreaTree areaTree, OutputStream stream) throws IOException {
- tree = areaTree;
- if (endNumber == -1) {
- endNumber = tree.getPages().size();
- }
-
- Vector numbers = getInvalidPageNumbers();
- for (int i = numbers.size() - 1; i > -1; i--)
- tree.getPages().removeElementAt(Integer.parseInt((String)numbers.elementAt(i)));
-
- }
-
- public void renderPage(Page page) {
- pageWidth = (int)((float)page.getWidth() / 1000f);
- pageHeight = (int)((float)page.getHeight() / 1000f);
- super.renderPage(page);
- }
-
-
- private Vector getInvalidPageNumbers() {
-
- Vector vec = new Vector();
- int max = tree.getPages().size();
- boolean isValid;
- for (int i = 0; i < max; i++) {
- isValid = true;
- if (i < startNumber || i > endNumber) {
- isValid = false;
- }
- else if (mode != EVEN_AND_ALL) {
- if (mode == EVEN && ((i + 1) % 2 != 0))
- isValid = false;
- else if (mode == ODD && ((i + 1) % 2 != 1))
- isValid = false;
- }
-
- if (!isValid)
- vec.add(i + "");
- }
-
- return vec;
- }
-
- void setCopies(int val) {
- copies = val;
- Vector copie = tree.getPages();
- for (int i = 1; i < copies; i++) {
- tree.getPages().addAll(copie);
- }
-
- }
-
- } // class PrintRenderer
-} // class PrintCommandLine
-
diff --git a/src/org/apache/fop/apps/XTCommandLine.java b/src/org/apache/fop/apps/XTCommandLine.java
deleted file mode 100644
index 78e8b8658..000000000
--- a/src/org/apache/fop/apps/XTCommandLine.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*-- $Id$ --
-
- ============================================================================
- The Apache Software License, Version 1.1
- ============================================================================
-
- Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modifica-
- tion, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- 3. The end-user documentation included with the redistribution, if any, must
- include the following acknowledgment: "This product includes software
- developed by the Apache Software Foundation (http://www.apache.org/)."
- Alternately, this acknowledgment may appear in the software itself, if
- and wherever such third-party acknowledgments normally appear.
-
- 4. The names "FOP" and "Apache Software Foundation" must not be used to
- endorse or promote products derived from this software without prior
- written permission. For written permission, please contact
- apache@apache.org.
-
- 5. Products derived from this software may not be called "Apache", nor may
- "Apache" appear in their name, without prior written permission of the
- Apache Software Foundation.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- This software consists of voluntary contributions made by many individuals
- on behalf of the Apache Software Foundation and was originally created by
- James Tauber <jtauber@jtauber.com>. For more information on the Apache
- Software Foundation, please see <http://www.apache.org/>.
-
- */
-
-package org.apache.fop.apps;
-
-import org.apache.fop.render.pdf.PDFRenderer;
-import org.apache.fop.fo.StandardElementMapping;
-import org.apache.fop.svg.SVGElementMapping;
-import org.apache.fop.messaging.MessageHandler;
-
-// James Clark
-import com.jclark.xsl.sax.XSLProcessor;
-import com.jclark.xsl.sax.XSLProcessorImpl;
-
-// SAX
-import org.xml.sax.Parser;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-// Java
-import java.io.*;
-import java.net.URL;
-
-/**
- * mainline class for full transformation (via XT) + formatting/rendering.
- *
- * gets input, stylesheet and output filenames from the command line
- * creates an implementation of XSLProcessor, passing it the stylesheet
- * treats XSLProcessor as SAXParser
- *
- */
-public class XTCommandLine {
-
- /**
- * mainline method.
- *
- * first command line argument is XML input file
- * second command line argument is XSL stylesheet file
- * third command line argument is outputfile
- */
- public static void main(String[] args) {
- String version = Version.getVersion();
- MessageHandler.errorln(version);
-
- if (args.length != 3) {
- MessageHandler.errorln("usage: java org.apache.fop.apps.XTCommandLine xml-file xsl-stylesheet pdf-file");
- System.exit(1);
- }
-
- Parser parser = createParser();
-
- if (parser == null) {
- MessageHandler.errorln("ERROR: Unable to create SAX parser");
- System.exit(1);
- }
-
- XSLProcessor xslProcessor = new XSLProcessorImpl();
- xslProcessor.setParser(parser);
-
- try {
- xslProcessor.loadStylesheet(fileInputSource(args[1]));
-
- XTDriver driver = new XTDriver();
- driver.setRenderer("org.apache.fop.render.pdf.PDFRenderer",
- version);
- driver.addElementMapping("org.apache.fop.fo.StandardElementMapping");
- driver.addElementMapping("org.apache.fop.svg.SVGElementMapping");
- driver.addPropertyList("org.apache.fop.fo.StandardPropertyListMapping");
- driver.addPropertyList("org.apache.fop.svg.SVGPropertyListMapping");
- OutputStream stream = new BufferedOutputStream(new FileOutputStream(args[2]));
- driver.setOutputStream(stream);
- driver.buildFOTree(xslProcessor, fileInputSource(args[0]));
- driver.format();
- driver.render();
- } catch (Exception e) {
- MessageHandler.errorln("FATAL ERROR: " + e.getMessage());
- System.exit(1);
- }
- }
-
- /**
- * creates a SAX parser, using the value of org.xml.sax.parser
- * defaulting to org.apache.xerces.parsers.SAXParser
- *
- * @return the created SAX parser
- */
- static Parser createParser() {
- String parserClassName =
- System.getProperty("org.xml.sax.parser");
- if (parserClassName == null) {
- parserClassName = "com.jclark.xml.sax.Driver";
- }
- org.apache.fop.messaging.MessageHandler.logln("using SAX parser " + parserClassName);
-
- try {
- return (Parser)
- Class.forName(parserClassName).newInstance();
- } catch (ClassNotFoundException e) {
- org.apache.fop.messaging.MessageHandler.errorln("Could not find " + parserClassName);
- } catch (InstantiationException e) {
- org.apache.fop.messaging.MessageHandler.errorln("Could not instantiate "
- + parserClassName);
- } catch (IllegalAccessException e) {
- org.apache.fop.messaging.MessageHandler.errorln("Could not access " + parserClassName);
- } catch (ClassCastException e) {
- org.apache.fop.messaging.MessageHandler.errorln(parserClassName + " is not a SAX driver");
- }
- return null;
- }
-
- /**
- * create an InputSource from a file name
- *
- * @param filename the name of the file
- * @return the InputSource created
- */
- protected static InputSource fileInputSource(String filename) {
-
- /* this code adapted from James Clark's in XT */
- File file = new File(filename);
- String path = file.getAbsolutePath();
- String fSep = System.getProperty("file.separator");
- if (fSep != null && fSep.length() == 1)
- path = path.replace(fSep.charAt(0), '/');
- if (path.length() > 0 && path.charAt(0) != '/')
- path = '/' + path;
- try {
- return new InputSource(new URL("file", null,
- path).toString());
- }
- catch (java.net.MalformedURLException e) {
- throw new Error("unexpected MalformedURLException");
- }
- }
-
-}
diff --git a/src/org/apache/fop/apps/XalanCommandLine.java b/src/org/apache/fop/apps/XalanCommandLine.java
deleted file mode 100644
index 09ef2ccc7..000000000
--- a/src/org/apache/fop/apps/XalanCommandLine.java
+++ /dev/null
@@ -1,344 +0,0 @@
-/*
-
- ============================================================================
- The Apache Software License, Version 1.1
- ============================================================================
-
- Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modifica-
- tion, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- 3. The end-user documentation included with the redistribution, if any, must
- include the following acknowledgment: "This product includes software
- developed by the Apache Software Foundation (http://www.apache.org/)."
- Alternately, this acknowledgment may appear in the software itself, if
- and wherever such third-party acknowledgments normally appear.
-
- 4. The names "Fop" and "Apache Software Foundation" must not be used to
- endorse or promote products derived from this software without prior
- written permission. For written permission, please contact
- apache@apache.org.
-
- 5. Products derived from this software may not be called "Apache", nor may
- "Apache" appear in their name, without prior written permission of the
- Apache Software Foundation.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- This software consists of voluntary contributions made by many individuals
- on behalf of the Apache Software Foundation and was originally created by
- James Tauber <jtauber@jtauber.com>. For more information on the Apache
- Software Foundation, please see <http://www.apache.org/>.
-
- */
-
-
-package org.apache.fop.apps;
-
-// SAX
-import org.xml.sax.XMLReader;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-
-// Java
-import java.io.*;
-import java.net.URL;
-
-/*
-// Xalan
-import org.apache.xalan.xpath.xml.XMLParserLiaison;
-import org.apache.xalan.xslt.XSLTInputSource;
-import org.apache.xalan.xslt.XSLTProcessor;
-import org.apache.xalan.xslt.XSLTProcessorFactory;
-import org.apache.xalan.xslt.XSLTResultTarget;
-*/
-
-// FOP
-import org.apache.fop.messaging.MessageHandler;
-import org.apache.fop.configuration.ConfigurationReader;
-import org.apache.fop.configuration.Configuration;
-import org.apache.fop.tools.xslt.XSLTransform;
-
-/**
- * mainline class.
- *
- * Gets input and output filenames from the command line.
- * Creates a SAX Parser (defaulting to Xerces).
- *
- */
-public class XalanCommandLine {
-
- private String foFile = null;
- private String pdfFile = null;
- private String xsltFile = null;
- private String userConfigFile = null;
- private String baseDir = null;
- private boolean dumpConfiguration = false;
-
- /** show a full dump on error */ //this should be implemented here too
- private static boolean errorDump = false;
-
- public XalanCommandLine(String[] args) {
- for (int i = 0; i < args.length; i++) {
- if (args[i].equals("-d") || args[i].equals("--full-error-dump")) {
- errorDump = true;
- } else if (args[i].equals("-x")) {
- dumpConfiguration = true;
- } else if ((args[i].charAt(0) == '-') &&
- (args[i].charAt(1) == 'c')) {
- userConfigFile = args[i].substring(2);
- } else if (args[i].charAt(0) == '-') {
- printUsage(args[i]);
- } else if (foFile == null) {
- foFile = args[i];
- } else if (xsltFile == null) {
- xsltFile = args[i];
- } else if (pdfFile == null) {
- pdfFile = args[i];
- } else {
- printUsage(args[i]);
- }
- }
- if (foFile == null || pdfFile == null || xsltFile == null) {
- printUsage(null);
- }
- }
-
-
- /*
- * shows usage info
- */
- public void printUsage(String arg) {
- if (arg != null) {
- MessageHandler.errorln("Unkown argument: '"+ arg + "'");
- }
- MessageHandler.errorln("Usage: java [-d] [-x]" +
- "[-cMyConfigFile] " +
- "org.apache.fop.apps.XalanCommandLine " + "xml-file xslt-file pdf-file");
- MessageHandler.errorln("Options:\n" + " -d or --full-error-dump Show stack traces upon error");
- MessageHandler.errorln(" -x dump configuration information");
- MessageHandler.errorln("-cMyConfigFile use values in configuration file MyConfigFile instead of/additional to default");
-
- System.exit(1);
- }
-
- /**
- * creates a SAX parser, using the value of org.xml.sax.parser
- * defaulting to org.apache.xerces.parsers.SAXParser
- *
- * @return the created SAX parser
- */
- static XMLReader createParser() {
- String parserClassName = System.getProperty("org.xml.sax.parser");
- if (parserClassName == null) {
- parserClassName = "org.apache.xerces.parsers.SAXParser";
- }
- org.apache.fop.messaging.MessageHandler.logln(
- "using SAX parser " + parserClassName);
-
- try {
- return (XMLReader) Class.forName(
- parserClassName).newInstance();
- } catch (ClassNotFoundException e) {
- org.apache.fop.messaging.MessageHandler.errorln(
- "Could not find " + parserClassName);
- }
- catch (InstantiationException e) {
- org.apache.fop.messaging.MessageHandler.errorln(
- "Could not instantiate " + parserClassName);
- }
- catch (IllegalAccessException e) {
- org.apache.fop.messaging.MessageHandler.errorln(
- "Could not access " + parserClassName);
- }
- catch (ClassCastException e) {
- org.apache.fop.messaging.MessageHandler.errorln(
- parserClassName + " is not a SAX driver");
- }
- return null;
- }
-
- /**
- * create an InputSource from a file name
- *
- * @param filename the name of the file
- * @return the InputSource created
- */
- protected static InputSource fileInputSource(String filename) {
-
- /* this code adapted from James Clark's in XT */
- File file = new File(filename);
- String path = file.getAbsolutePath();
- String fSep = System.getProperty("file.separator");
- if (fSep != null && fSep.length() == 1)
- path = path.replace(fSep.charAt(0), '/');
- if (path.length() > 0 && path.charAt(0) != '/')
- path = '/' + path;
- try {
- return new InputSource(new URL("file", null, path).toString());
- } catch (java.net.MalformedURLException e) {
- throw new Error("unexpected MalformedURLException");
- }
- }
-
-
- /**
- * mainline method
- *
- * first command line argument is xml input file
- * second command line argument is xslt file which commands the conversion from xml to xsl:fo
- * third command line argument is the output file
- *
- * @param command line arguments
- */
- public void run () {
- Driver driver = new Driver();
- if (errorDump) {
- driver.setErrorDump(true);
- }
- if (userConfigFile != null) {
- driver.loadUserconfiguration(userConfigFile);
- }
- if (dumpConfiguration) {
- Configuration.dumpConfiguration();
- System.exit(0);
- }
-
- driver.setBaseDir(foFile);
- String version = Version.getVersion();
- MessageHandler.logln(version);
-
- XMLReader parser = createParser();
-
- if (parser == null) {
- MessageHandler.errorln("ERROR: Unable to create SAX parser");
- System.exit(1);
- }
-
- // setting the parser features
- try {
- parser.setFeature("http://xml.org/sax/features/namespace-prefixes",
- true);
- } catch (SAXException e) {
- MessageHandler.errorln("Error in setting up parser feature namespace-prefixes");
- MessageHandler.errorln("You need a parser which supports SAX version 2");
- System.exit(1);
- }
-
-
- try {
- java.io.Writer writer;
- java.io.Reader reader;
- boolean usefile = false;
-
- MessageHandler.logln("transforming to xsl:fo markup");
-
-
- // create a Writer
- // the following is an ugly hack to allow processing of larger files
- // if xml file size is larger than 700 kb write the fo:file to disk
- if ((new File(foFile).length()) > 500000) {
- writer = new FileWriter(pdfFile + ".tmp");
- usefile = true;
- } else {
- writer = new StringWriter();
- }
-
- // Use XSLTProcessorFactory to instantiate an XSLTProcessor.
- // XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
-
- // Create the 3 objects the XSLTProcessor needs to perform the transformation.
- // Fix up the args...
- // XMLParserLiaison xmlPL = processor.getXMLProcessorLiaison();
- // URL urlTmp = xmlPL.getURLFromString(foFile, null);
- // MessageHandler.errorln("xml: " + urlTmp);
- /* XSLTInputSource xmlSource =
- new XSLTInputSource (urlTmp.toString());
- */
- // urlTmp = xmlPL.getURLFromString(xsltFile, null);
- // MessageHandler.errorln("xslt: " + urlTmp);
- /* XSLTInputSource xslSheet =
- new XSLTInputSource (urlTmp.toString());
-
- XSLTResultTarget xmlResult = new XSLTResultTarget (writer);
- */
- // Perform the transformation.
- // processor.process(xmlSource, xslSheet, xmlResult);
-
- XSLTransform.transform(foFile, xsltFile, writer);
-
- if (usefile) {
- reader = new FileReader(pdfFile + ".tmp");
- } else {
- // create a input source containing the xsl:fo file which can be fed to Fop
- reader = new StringReader(writer.toString());
- }
- writer.flush();
- writer.close();
-
- //set Driver methods to start Fop processing
- driver.setRenderer("org.apache.fop.render.pdf.PDFRenderer",
- version);
- driver.addElementMapping("org.apache.fop.fo.StandardElementMapping");
- driver.addElementMapping("org.apache.fop.svg.SVGElementMapping");
- driver.addElementMapping("org.apache.fop.extensions.ExtensionElementMapping");
- driver.addPropertyList("org.apache.fop.fo.StandardPropertyListMapping");
- driver.addPropertyList("org.apache.fop.svg.SVGPropertyListMapping");
- driver.addPropertyList("org.apache.fop.extensions.ExtensionPropertyListMapping");
-
- OutputStream stream = new BufferedOutputStream(new FileOutputStream(pdfFile));
- driver.setOutputStream(stream);
- driver.buildFOTree(parser, new InputSource(reader));
- reader.close();
- driver.format();
- driver.render();
- if (usefile) {
- new File (pdfFile + ".tmp").delete();
- }
- stream.flush();
- stream.close();
- }
- catch (Exception e) {
- MessageHandler.errorln("FATAL ERROR: " + e.getMessage());
- if (errorDump) {
- e.printStackTrace();
- }
- System.exit(1);
- }
- }
-
- /**
- * mainline method
- *
- * first command line argument is xml input file
- * second command line argument is xslt file
- * third command line argument is the target pdf file
- *
- * @param command line arguments
- */
- public static void main(String[] args) {
- XalanCommandLine xcmdLine = new XalanCommandLine(args);
- xcmdLine.run();
-
- }
-
-}