You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by vg...@apache.org on 2003/05/08 03:03:49 UTC
cvs commit: cocoon-2.0/src/java/org/apache/cocoon/xml/dom SVGBuilder.java
vgritsenko 2003/05/07 18:03:49
Modified: lib jars.xml
src/java/org/apache/cocoon/xml/dom SVGBuilder.java
Added: lib/optional batik-all-1.5b5.jar
Removed: lib/optional batik-all-1.5b2.jar
Log:
Backport from 2.1 SVG serializer fixes. Update batik library to 1.5b5.
Revision Changes Path
1.5 +1 -1 cocoon-2.0/lib/jars.xml
Index: jars.xml
===================================================================
RCS file: /home/cvs/cocoon-2.0/lib/jars.xml,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- jars.xml 17 Mar 2003 10:35:38 -0000 1.4
+++ jars.xml 8 May 2003 01:03:47 -0000 1.5
@@ -253,7 +253,7 @@
the Scalable Vector Graphics (SVG) format for various purposes, such as
viewing, generation or manipulation.</description>
<used-by>SVG serializer (SVG to JPG, PNG)</used-by>
- <lib>optional/batik-all-1.5b2.jar</lib>
+ <lib>optional/batik-all-1.5b5.jar</lib>
<homepage>http://xml.apache.org/batik/</homepage>
</file>
<file>
1.1 cocoon-2.0/lib/optional/batik-all-1.5b5.jar
<<Binary file>>
1.3 +44 -12 cocoon-2.0/src/java/org/apache/cocoon/xml/dom/SVGBuilder.java
Index: SVGBuilder.java
===================================================================
RCS file: /home/cvs/cocoon-2.0/src/java/org/apache/cocoon/xml/dom/SVGBuilder.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SVGBuilder.java 28 Apr 2003 06:00:19 -0000 1.2
+++ SVGBuilder.java 8 May 2003 01:03:49 -0000 1.3
@@ -57,6 +57,10 @@
import org.apache.log.Logger;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
+import org.xml.sax.Locator;
+
+import java.net.MalformedURLException;
+import java.net.URL;
/**
* The <code>SVGBuilder</code> is a utility class that will generate a
@@ -68,6 +72,8 @@
public class SVGBuilder extends SAXSVGDocumentFactory implements XMLConsumer, Loggable {
protected Logger log;
+ protected Locator locator;
+
private static final String SAX_PARSER
= "org.apache.xerces.parsers.SAXParser";
@@ -89,6 +95,10 @@
}
}
+ protected Logger getLogger() {
+ return this.log;
+ }
+
/**
* Return the newly built Document.
*/
@@ -101,43 +111,65 @@
*
* @exception SAXException If this method was not called appropriately.
*/
- public void startDocument()
- throws SAXException {
+ public void startDocument() throws SAXException {
try {
// Create SVG Document
String namespaceURI = SVGDOMImplementation.SVG_NAMESPACE_URI;
this.document = implementation.createDocument(namespaceURI, "svg", null);
super.startDocument();
+ // Add svg, and SVG_NAMESPACE to SAXDocumentFactory namespace handling.
+ // This ties 'svg' prefix used above to the svg namespace uri.
+ namespaces.put("svg", SVGDOMImplementation.SVG_NAMESPACE_URI);
+ } catch (SAXException se) {
+ throw se;
} catch (Exception ex){
- log.error("SVGBuilder: startDocument", ex);
- throw new SAXException("SVGBuilder: startDocument", ex);
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Got exception in startDocument, rethrowing", ex);
+ }
+ throw new SAXException("Exception in startDocument", ex);
}
}
+ public void setDocumentLocator(Locator locator) {
+ this.locator = locator;
+ super.setDocumentLocator(locator);
+ }
+
/**
* Receive notification of the beginning of a document.
*
* @exception SAXException If this method was not called appropriately.
*/
- public void endDocument ()
- throws SAXException {
+ public void endDocument() throws SAXException {
try {
super.endDocument();
// FIXME: Hack.
- ((org.apache.batik.dom.svg.SVGOMDocument)this.document).setURLObject(new java.net.URL("http://xml.apache.org"));
+ try {
+ if (this.locator != null) {
+ ((org.apache.batik.dom.svg.SVGOMDocument)super.document).setURLObject(new URL(this.locator.getSystemId()));
+ } else {
+ getLogger().warn("setDocumentLocator was not called, URI resolution will not work");
+ }
+ } catch (MalformedURLException e) {
+ getLogger().warn("Unable to set document base URI to " + this.locator.getSystemId(), e);
+ ((org.apache.batik.dom.svg.SVGOMDocument)super.document).setURLObject(new URL("http://xml.apache.org/"));
+ }
this.notify(this.document);
+ } catch (SAXException se) {
+ throw se;
} catch (Exception ex){
- log.error("SVGBuilder: endDocument", ex);
- throw new SAXException("SVGBuilder: endDocument", ex);
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Got exception in endDocument, rethrowing", ex);
+ }
+ throw new SAXException("Exception in endDocument", ex);
}
}
/**
* Receive notification of a successfully completed DOM tree generation.
*/
- protected void notify(Document doc)
- throws SAXException {
+ protected void notify(Document doc) throws SAXException {
}
}