xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thomas.dewe...@kodak.com
Subject Re: org.apache.batik.dom.util.SAXDocumentFactory -- svgplugin calling startElement() before createDocument()
Date Thu, 03 Apr 2008 10:18:17 GMT
Hi Marshall,

"Marshall Flax" <marshall.flax@gmail.com> wrote on 03/30/2008 03:05:50 PM:

> org.apache.batik.dom.util.SAXDocumentFactory.startElement() --
> apparently because createDocument() is never called. This results in a
> stack trace (Europa Eclipse, 1.5 OSX 10.4) like

   It looks like 'EclipseSAXSVGDocumentFactory' is subclassing
our 'SAXDocumentFactory' and overriding our createDocument and not
setting the parser to the baseclass.  I would consider this
bad on their part.

   That said, I think it would be good to add defensive code.
In this case I think the fact that isStandalone and xmlVersion
aren't set should cause no major issues (it looks like those
values are used to set features on the SVG Document object so
I'm guessing that this will cause a small non-conformance).

   In short I think both code bases should be updated.

> However, a simple patch like

   I don't like your patch. I would wrap just the two
'try' blocks with an 'if':

Index: sources/org/apache/batik/dom/util/SAXDocumentFactory.java
===================================================================
--- sources/org/apache/batik/dom/util/SAXDocumentFactory.java   (revision
636165)
+++ sources/org/apache/batik/dom/util/SAXDocumentFactory.java   (working
copy)
@@ -559,16 +559,18 @@

         if (inProlog) {
             inProlog = false;
-            try {
-                isStandalone = parser.getFeature
-                    ("http://xml.org/sax/features/is-standalone");
-            } catch (SAXNotRecognizedException ex) {
+            if (parser != null) {
+                try {
+                    isStandalone = parser.getFeature
+                        ("http://xml.org/sax/features/is-standalone");
+                } catch (SAXNotRecognizedException ex) {
+                }
+                try {
+                    xmlVersion = (String) parser.getProperty
+
("http://xml.org/sax/properties/document-xml-version");
+                } catch (SAXNotRecognizedException ex) {
+                }
             }
-            try {
-                xmlVersion = (String) parser.getProperty
-
("http://xml.org/sax/properties/document-xml-version");
-            } catch (SAXNotRecognizedException ex) {
-            }
         }

         // Namespaces resolution
Mime
View raw message