gmazza 2004/07/20 14:28:50
Modified: src/java/org/apache/fop/apps CommandLineOptions.java
FOFileHandler.java
src/java/org/apache/fop/fo/extensions/svg
BatikExtensionElementMapping.java
SVGElementMapping.java
src/java/org/apache/fop/image XMLImage.java
src/java/org/apache/fop/svg SVGUserAgent.java
Log:
1.) Moved the SAXParser-creating method from FOFileHandler to CommandLineOptions,
the latter being the class directly using it.
2.) Decoupled the SVG classes from apps.FOFileHandler, the SVG classes for some
reason
want a string containing a name of a SAXParser. We'll need to look in the future for
the actual need for this--normally error messages are done by the caller, not
the callee. It would appear that Batik can generate a SAXParser name by default,
and use that when not explicitly overridden by the caller.
Revision Changes Path
1.25 +17 -1 xml-fop/src/java/org/apache/fop/apps/CommandLineOptions.java
Index: CommandLineOptions.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/apps/CommandLineOptions.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- CommandLineOptions.java 9 Jul 2004 17:27:12 -0000 1.24
+++ CommandLineOptions.java 20 Jul 2004 21:28:50 -0000 1.25
@@ -34,6 +34,7 @@
// SAX
import org.xml.sax.XMLReader;
import org.xml.sax.SAXException;
+import javax.xml.parsers.SAXParserFactory;
// avalon configuration
import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
@@ -434,7 +435,7 @@
if (userConfigFile == null) {
return;
}
- XMLReader parser = FOFileHandler.createParser();
+ XMLReader parser = createParser();
DefaultConfigurationBuilder configBuilder
= new DefaultConfigurationBuilder(parser);
Configuration userConfig = null;
@@ -719,5 +720,20 @@
}
}
+ /**
+ * Creates <code>XMLReader</code> object using default
+ * <code>SAXParserFactory</code>
+ * @return the created <code>XMLReader</code>
+ * @throws FOPException if the parser couldn't be created or configured for
proper operation.
+ */
+ private XMLReader createParser() throws FOPException {
+ try {
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+ factory.setNamespaceAware(true);
+ return factory.newSAXParser().getXMLReader();
+ } catch (Exception e) {
+ throw new FOPException("Couldn't create XMLReader", e);
+ }
+ }
}
1.6 +2 -35 xml-fop/src/java/org/apache/fop/apps/FOFileHandler.java
Index: FOFileHandler.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/apps/FOFileHandler.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- FOFileHandler.java 20 Jul 2004 03:39:24 -0000 1.5
+++ FOFileHandler.java 20 Jul 2004 21:28:50 -0000 1.6
@@ -27,9 +27,7 @@
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
-//JAXP
-import javax.xml.parsers.SAXParserFactory;
-import javax.xml.parsers.ParserConfigurationException;
+// JAXP
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.Source;
@@ -103,37 +101,6 @@
} catch (Exception e) {
throw new FOPException(e);
- }
- }
-
- /**
- * Creates <code>XMLReader</code> object using default
- * <code>SAXParserFactory</code>
- * @return the created <code>XMLReader</code>
- * @throws FOPException if the parser couldn't be created or configured for
proper operation.
- */
- protected static XMLReader createParser() throws FOPException {
- try {
- SAXParserFactory factory = SAXParserFactory.newInstance();
- factory.setNamespaceAware(true);
- return factory.newSAXParser().getXMLReader();
- } catch (SAXException se) {
- throw new FOPException("Couldn't create XMLReader", se);
- } catch (ParserConfigurationException pce) {
- throw new FOPException("Couldn't create XMLReader", pce);
- }
- }
-
- /**
- * Returns the fully qualified classname of the standard XML parser for FOP
- * to use.
- * @return the XML parser classname
- */
- public static final String getParserClassName() {
- try {
- return createParser().getClass().getName();
- } catch (FOPException e) {
- return null;
}
}
}
1.5 +17 -3
xml-fop/src/java/org/apache/fop/fo/extensions/svg/BatikExtensionElementMapping.java
Index: BatikExtensionElementMapping.java
===================================================================
RCS file:
/home/cvs/xml-fop/src/java/org/apache/fop/fo/extensions/svg/BatikExtensionElementMapping.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- BatikExtensionElementMapping.java 15 Jun 2004 00:30:43 -0000 1.4
+++ BatikExtensionElementMapping.java 20 Jul 2004 21:28:50 -0000 1.5
@@ -19,9 +19,9 @@
package org.apache.fop.fo.extensions.svg;
import java.util.HashMap;
+import javax.xml.parsers.SAXParserFactory;
import org.apache.batik.util.XMLResourceDescriptor;
-import org.apache.fop.apps.FOFileHandler;
import org.apache.fop.fo.ElementMapping;
import org.apache.fop.fo.FONode;
@@ -37,6 +37,20 @@
namespaceURI = URI;
}
+ /**
+ * Returns the fully qualified classname of an XML parser for
+ * Batik classes that apparently need it (error messages, perhaps)
+ * @return an XML parser classname
+ */
+ private final String getAParserClassName() {
+ try {
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+ return factory.newSAXParser().getXMLReader().getClass().getName();
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
protected void initialize() {
if (foObjs == null && batikAvail == true) {
// this sets the parser that will be used
@@ -44,7 +58,7 @@
// normally the user agent value is used
try {
XMLResourceDescriptor.setXMLParserClassName(
- FOFileHandler.getParserClassName());
+ getAParserClassName());
foObjs = new HashMap();
foObjs.put("batik", new SE());
1.5 +17 -3
xml-fop/src/java/org/apache/fop/fo/extensions/svg/SVGElementMapping.java
Index: SVGElementMapping.java
===================================================================
RCS file:
/home/cvs/xml-fop/src/java/org/apache/fop/fo/extensions/svg/SVGElementMapping.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SVGElementMapping.java 15 Jun 2004 00:30:43 -0000 1.4
+++ SVGElementMapping.java 20 Jul 2004 21:28:50 -0000 1.5
@@ -19,10 +19,10 @@
package org.apache.fop.fo.extensions.svg;
import java.util.HashMap;
+import javax.xml.parsers.SAXParserFactory;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.ElementMapping;
-import org.apache.fop.apps.FOFileHandler;
import org.apache.batik.util.XMLResourceDescriptor;
import org.apache.batik.dom.svg.SVGDOMImplementation;
@@ -40,6 +40,20 @@
namespaceURI = URI;
}
+ /**
+ * Returns the fully qualified classname of an XML parser for
+ * Batik classes that apparently need it (error messages, perhaps)
+ * @return an XML parser classname
+ */
+ private final String getAParserClassName() {
+ try {
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+ return factory.newSAXParser().getXMLReader().getClass().getName();
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
protected void initialize() {
if (foObjs == null && batik == true) {
// this sets the parser that will be used
@@ -47,7 +61,7 @@
// normally the user agent value is used
try {
XMLResourceDescriptor.setXMLParserClassName(
- FOFileHandler.getParserClassName());
+ getAParserClassName());
foObjs = new HashMap();
foObjs.put("svg", new SE());
1.8 +10 -9 xml-fop/src/java/org/apache/fop/image/XMLImage.java
Index: XMLImage.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/image/XMLImage.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- XMLImage.java 27 Feb 2004 17:47:46 -0000 1.7
+++ XMLImage.java 20 Jul 2004 21:28:50 -0000 1.8
@@ -20,9 +20,7 @@
// Java
import org.w3c.dom.Document;
-
-// FOP
-import org.apache.fop.apps.FOFileHandler;
+import javax.xml.parsers.SAXParserFactory;
/**
* This is an implementation for XML-based images such as SVG.
@@ -48,14 +46,17 @@
}
/**
- * creates a SAX parser, using the value of org.xml.sax.parser
- * defaulting to org.apache.xerces.parsers.SAXParser
- *
- * @return the created SAX parser
+ * Returns the fully qualified classname of an XML parser for
+ * Batik classes that apparently need it (error messages, perhaps)
+ * @return an XML parser classname
*/
public static String getParserName() {
- String parserClassName = FOFileHandler.getParserClassName();
- return parserClassName;
+ try {
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+ return factory.newSAXParser().getXMLReader().getClass().getName();
+ } catch (Exception e) {
+ return null;
+ }
}
/**
1.13 +7 -2 xml-fop/src/java/org/apache/fop/svg/SVGUserAgent.java
Index: SVGUserAgent.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/svg/SVGUserAgent.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- SVGUserAgent.java 12 May 2004 23:19:53 -0000 1.12
+++ SVGUserAgent.java 20 Jul 2004 21:28:50 -0000 1.13
@@ -18,7 +18,7 @@
package org.apache.fop.svg;
-import org.apache.fop.apps.FOFileHandler;
+import javax.xml.parsers.SAXParserFactory;
import org.apache.batik.bridge.UserAgentAdapter;
import org.apache.commons.logging.Log;
@@ -135,7 +135,12 @@
* @return the XML parser class name
*/
public String getXMLParserClassName() {
- return FOFileHandler.getParserClassName();
+ try {
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+ return factory.newSAXParser().getXMLReader().getClass().getName();
+ } catch (Exception e) {
+ return null;
+ }
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]