You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by br...@apache.org on 2003/08/13 10:44:54 UTC

cvs commit: cocoon-2.1/src/blocks/batik/java/org/apache/cocoon/xml/dom SVGBuilder.java

bruno       2003/08/13 01:44:54

  Modified:    src/blocks/batik/java/org/apache/cocoon/xml/dom
                        SVGBuilder.java
  Log:
  Set base URI to http://localhost/ if setDocumentLocator wasn't called.
  
  Revision  Changes    Path
  1.5       +16 -6     cocoon-2.1/src/blocks/batik/java/org/apache/cocoon/xml/dom/SVGBuilder.java
  
  Index: SVGBuilder.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/batik/java/org/apache/cocoon/xml/dom/SVGBuilder.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SVGBuilder.java	7 May 2003 19:15:02 -0000	1.4
  +++ SVGBuilder.java	13 Aug 2003 08:44:54 -0000	1.5
  @@ -52,6 +52,8 @@
   
   import org.apache.avalon.framework.logger.LogEnabled;
   import org.apache.avalon.framework.logger.Logger;
  +import org.apache.avalon.framework.activity.Disposable;
  +import org.apache.avalon.excalibur.pool.Recyclable;
   
   import org.apache.batik.dom.svg.SAXSVGDocumentFactory;
   import org.apache.batik.dom.svg.SVGDOMImplementation;
  @@ -72,7 +74,7 @@
    * @author <a href="mailto:dims@yahoo.com">Davanum Srinivas</a>
    * @version CVS $Id$
    */
  -public class SVGBuilder extends SAXSVGDocumentFactory implements XMLConsumer, LogEnabled {
  +public class SVGBuilder extends SAXSVGDocumentFactory implements XMLConsumer, LogEnabled, Recyclable {
       protected Logger log;
   
       protected Locator locator;
  @@ -148,15 +150,18 @@
               super.endDocument();
   
               // FIXME: Hack.
  +            URL baseURL = null;
               try {
                   if (this.locator != null) {
  -                    ((org.apache.batik.dom.svg.SVGOMDocument)super.document).setURLObject(new URL(this.locator.getSystemId()));
  +                    baseURL = new URL(this.locator.getSystemId());
                   } else {
  -                    getLogger().warn("setDocumentLocator was not called, URI resolution will not work");
  +                    baseURL = new URL("http://localhost/");
  +                    getLogger().warn("setDocumentLocator was not called, will use http://localhost/ as base URI");
                   }
  +                ((org.apache.batik.dom.svg.SVGOMDocument)super.document).setURLObject(baseURL);
               } 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/"));
  +                getLogger().warn("Unable to set document base URI to " + baseURL + ", will default to http://localhost/", e);
  +                ((org.apache.batik.dom.svg.SVGOMDocument)super.document).setURLObject(new URL("http://localhost/"));
               }
   
               notify(super.document);
  @@ -175,4 +180,9 @@
        */
       protected void notify(Document doc) throws SAXException {
       }
  +
  +    public void recycle() {
  +        locator = null;
  +    }
  +
   }