aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMaximilian Berger <maxberger@apache.org>2008-02-21 18:22:22 +0000
committerMaximilian Berger <maxberger@apache.org>2008-02-21 18:22:22 +0000
commitaaef3aaef54068e37711a2ef05cf5be6b99eccdb (patch)
tree86cee34e2c00276632845ca3639490e16441c4e1 /src
parent0c0480eb79ef67c1ef94e276d1ae72766ee9501d (diff)
downloadxmlgraphics-fop-aaef3aaef54068e37711a2ef05cf5be6b99eccdb.tar.gz
xmlgraphics-fop-aaef3aaef54068e37711a2ef05cf5be6b99eccdb.zip
Turned on XInclude processing for the main source given on the command line.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@629902 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/java/org/apache/fop/cli/InputHandler.java31
1 files changed, 28 insertions, 3 deletions
diff --git a/src/java/org/apache/fop/cli/InputHandler.java b/src/java/org/apache/fop/cli/InputHandler.java
index 89977beb7..a49c978f6 100644
--- a/src/java/org/apache/fop/cli/InputHandler.java
+++ b/src/java/org/apache/fop/cli/InputHandler.java
@@ -21,9 +21,13 @@ package org.apache.fop.cli;
// Imported java.io classes
import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
import java.io.OutputStream;
import java.util.Vector;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParserFactory;
import javax.xml.transform.ErrorListener;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
@@ -31,17 +35,20 @@ import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.sax.SAXResult;
+import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FopFactory;
import org.apache.fop.render.awt.viewer.Renderable;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
/**
* Class for handling files input from command line
@@ -133,11 +140,29 @@ public class InputHandler implements ErrorListener, Renderable {
}
/**
- * Creates a Source for the main input file.
+ * Creates a Source for the main input file. Processes XInclude if
+ * available in the XML parser.
+ *
* @return the Source for the main input file
*/
protected Source createMainSource() {
- return new StreamSource(this.sourcefile);
+ Source result;
+ try {
+ InputSource is = new InputSource(new FileInputStream(
+ this.sourcefile));
+ SAXParserFactory spf = SAXParserFactory.newInstance();
+ spf.setNamespaceAware(true);
+ spf.setXIncludeAware(true);
+ XMLReader xr = spf.newSAXParser().getXMLReader();
+ result = new SAXSource(xr, is);
+ } catch (SAXException e) {
+ result = new StreamSource(this.sourcefile);
+ } catch (IOException e) {
+ result = new StreamSource(this.sourcefile);
+ } catch (ParserConfigurationException e) {
+ result = new StreamSource(this.sourcefile);
+ }
+ return result;
}
/**