You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by ma...@apache.org on 2008/02/21 19:22:23 UTC

svn commit: r629902 - in /xmlgraphics/fop/trunk: src/java/org/apache/fop/cli/InputHandler.java status.xml

Author: maxberger
Date: Thu Feb 21 10:22:22 2008
New Revision: 629902

URL: http://svn.apache.org/viewvc?rev=629902&view=rev
Log:
Turned on XInclude processing for the main source given on the command line.

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/InputHandler.java
    xmlgraphics/fop/trunk/status.xml

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/InputHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/InputHandler.java?rev=629902&r1=629901&r2=629902&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/InputHandler.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/InputHandler.java Thu Feb 21 10:22:22 2008
@@ -21,9 +21,13 @@
 
 // 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.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 @@
     }
     
     /**
-     * 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;
     }
     
     /**

Modified: xmlgraphics/fop/trunk/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?rev=629902&r1=629901&r2=629902&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/status.xml (original)
+++ xmlgraphics/fop/trunk/status.xml Thu Feb 21 10:22:22 2008
@@ -28,6 +28,9 @@
 
   <changes>
     <release version="FOP Trunk">
+      <action context="Code" dev="MB" type="add">
+        Turned on XInclude processing for the main source given on the command line.
+      </action>
       <action context="Fonts" dev="JM" type="fix" fixed-bug="44451" due-to="Justus Piater">
         Improved the font auto-detection so fonts accessed using the font-family name are
         selected with higher accuracy.



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org


Re: svn commit: r629902 - in /xmlgraphics/fop/trunk: src/java/org/apache/fop/cli/InputHandler.java status.xml

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
setFeature may not work in this case as there's no feature ID defined by
the SAX project for XInclude. The feature ID would be parser specific.

As an alternative, we could use Reflection to enable the feature if a
JAXP 1.3 implementation is available.

On 22.02.2008 15:05:34 Max Berger wrote:
> Jeremias,
> 
> give me two days... If i haven't found a java 1.4 compatible version on
> sunday feel free to revert the patch. Afaik setting some properties on
> the SAXparser should have the same effect.
> 
> Max
> 
> 
> On Fre, 2008-02-22 at 14:37 +0100, Jeremias Maerki wrote:
> > Hmm. Now this is one of those cases where we have to be careful. With
> > this change FOP doesn't compile on Java 1.4 without putting a JAXP 1.3
> > in <jre>/lib/endorsed directory or using the -Xbootclasspath argument.
> > And those running it will have the same problem. If we really want to do
> > this, putting the XML JARs (including xml-apis(-ext).jar) into
> > <fop>/lib/endorsed will make things easier. And maybe we should dedicate
> > a special page in our docs on this topic.
> > 
> > On 21.02.2008 19:22:23 maxberger wrote:
> > > Author: maxberger
> > > Date: Thu Feb 21 10:22:22 2008
> > > New Revision: 629902
> > > 
> > > URL: http://svn.apache.org/viewvc?rev=629902&view=rev
> > > Log:
> > > Turned on XInclude processing for the main source given on the command line.
> > > 
> > > Modified:
> > >     xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/InputHandler.java
> > >     xmlgraphics/fop/trunk/status.xml
> > > 
> > > Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/InputHandler.java
> > > URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/InputHandler.java?rev=629902&r1=629901&r2=629902&view=diff
> > > ==============================================================================
> > > --- xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/InputHandler.java (original)
> > > +++ xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/InputHandler.java Thu Feb 21 10:22:22 2008
> > <snip/>
> > > +        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;
> > <snip/>
> > 
> > 
> > 
> > Jeremias Maerki
> > 
> mfG
> 
> Max Berger
> e-mail: max@berger.name
> 
> -- 
> OpenPG ID: E81592BC   Print: F489F8759D4132923EC4 BC7E072AB73AE81592BC
> For information about me and my work please see http://max.berger.name
> 




Jeremias Maerki


Re: svn commit: r629902 - in /xmlgraphics/fop/trunk: src/java/org/apache/fop/cli/InputHandler.java status.xml

Posted by Max Berger <ma...@berger.name>.
Jeremias,

give me two days... If i haven't found a java 1.4 compatible version on
sunday feel free to revert the patch. Afaik setting some properties on
the SAXparser should have the same effect.

Max


On Fre, 2008-02-22 at 14:37 +0100, Jeremias Maerki wrote:
> Hmm. Now this is one of those cases where we have to be careful. With
> this change FOP doesn't compile on Java 1.4 without putting a JAXP 1.3
> in <jre>/lib/endorsed directory or using the -Xbootclasspath argument.
> And those running it will have the same problem. If we really want to do
> this, putting the XML JARs (including xml-apis(-ext).jar) into
> <fop>/lib/endorsed will make things easier. And maybe we should dedicate
> a special page in our docs on this topic.
> 
> On 21.02.2008 19:22:23 maxberger wrote:
> > Author: maxberger
> > Date: Thu Feb 21 10:22:22 2008
> > New Revision: 629902
> > 
> > URL: http://svn.apache.org/viewvc?rev=629902&view=rev
> > Log:
> > Turned on XInclude processing for the main source given on the command line.
> > 
> > Modified:
> >     xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/InputHandler.java
> >     xmlgraphics/fop/trunk/status.xml
> > 
> > Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/InputHandler.java
> > URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/InputHandler.java?rev=629902&r1=629901&r2=629902&view=diff
> > ==============================================================================
> > --- xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/InputHandler.java (original)
> > +++ xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/InputHandler.java Thu Feb 21 10:22:22 2008
> <snip/>
> > +        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;
> <snip/>
> 
> 
> 
> Jeremias Maerki
> 
mfG

Max Berger
e-mail: max@berger.name

-- 
OpenPG ID: E81592BC   Print: F489F8759D4132923EC4 BC7E072AB73AE81592BC
For information about me and my work please see http://max.berger.name


Re: svn commit: r629902 - in /xmlgraphics/fop/trunk: src/java/org/apache/fop/cli/InputHandler.java status.xml

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
Hmm. Now this is one of those cases where we have to be careful. With
this change FOP doesn't compile on Java 1.4 without putting a JAXP 1.3
in <jre>/lib/endorsed directory or using the -Xbootclasspath argument.
And those running it will have the same problem. If we really want to do
this, putting the XML JARs (including xml-apis(-ext).jar) into
<fop>/lib/endorsed will make things easier. And maybe we should dedicate
a special page in our docs on this topic.

On 21.02.2008 19:22:23 maxberger wrote:
> Author: maxberger
> Date: Thu Feb 21 10:22:22 2008
> New Revision: 629902
> 
> URL: http://svn.apache.org/viewvc?rev=629902&view=rev
> Log:
> Turned on XInclude processing for the main source given on the command line.
> 
> Modified:
>     xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/InputHandler.java
>     xmlgraphics/fop/trunk/status.xml
> 
> Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/InputHandler.java
> URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/InputHandler.java?rev=629902&r1=629901&r2=629902&view=diff
> ==============================================================================
> --- xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/InputHandler.java (original)
> +++ xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/InputHandler.java Thu Feb 21 10:22:22 2008
<snip/>
> +        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;
<snip/>



Jeremias Maerki