]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Code changed to set the Base URL in FOUserAgent, which allows
authorGlen Mazza <gmazza@apache.org>
Tue, 16 Mar 2004 05:25:16 +0000 (05:25 +0000)
committerGlen Mazza <gmazza@apache.org>
Tue, 16 Mar 2004 05:25:16 +0000 (05:25 +0000)
image.ImageFactory to use this value in order to determine locations
of images given relative to the input source file.

e.g. c:\xml-fop>fop examples\fo\basic\images.fo images.pdf

will now run correctly.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197450 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/apps/Driver.java
src/java/org/apache/fop/apps/FOFileHandler.java
src/java/org/apache/fop/apps/InputHandler.java
src/java/org/apache/fop/apps/XSLTInputHandler.java
src/java/org/apache/fop/image/ImageFactory.java

index ec4b11aa4f0269acdcf068cb763a2867f44189cf..55059cff11631fae3d481bf663627f4e0ae4758a 100644 (file)
@@ -248,7 +248,6 @@ public class Driver implements LogEnabled {
         if (userAgent == null) {
             userAgent = new FOUserAgent();
             userAgent.enableLogging(getLogger());
-            userAgent.setBaseURL("");
         }
         return userAgent;
     }
@@ -572,6 +571,7 @@ public class Driver implements LogEnabled {
     public synchronized void render(InputHandler inputHandler)
                 throws FOPException {
         XMLReader parser = inputHandler.getParser();
+        userAgent.setBaseURL(inputHandler.getBaseURL());
         render(parser, inputHandler.getInputSource());
     }
 
index 28226e6770945fbeac3d933b693f3987f2143a71..acefd0cdaa888c04f52c65c665803d70e4d60a68 100644 (file)
@@ -45,6 +45,12 @@ public class FOFileHandler extends InputHandler {
      */
     public FOFileHandler(File fofile) {
         this.fofile = fofile;
+        try {
+            baseURL =
+                new File(fofile.getAbsolutePath()).getParentFile().toURL().toExternalForm();
+        } catch (Exception e) {
+            baseURL = "";
+        }
     }
 
     /**
@@ -55,7 +61,6 @@ public class FOFileHandler extends InputHandler {
         this.foURL = url;
     }
 
-    
     /**
      * @see org.apache.fop.apps.InputHandler#getInputSource()
      */
index 9597ee324607cf0ae3ecbcc9ac015f34098ad91d..acb6c50e9f83eab13c13af69d11b8a259f0b62d4 100644 (file)
@@ -39,6 +39,16 @@ public abstract class InputHandler {
      */
     public abstract InputSource getInputSource();
 
+    protected String baseURL = null;
+    
+    /**
+     * Get the base URL associated with this input source
+     * @return the input source
+     */
+    public String getBaseURL() {
+        return baseURL;
+    }
+
     /**
      * Get the SAX parser associated with this input handler.
      * @return the SAX parser
index 9634f073f22de1bde04d18335668e52bd3f00ccd..88771f6b3d8bdafa2cc17da3e1140d6a22e20cdd 100644 (file)
@@ -57,6 +57,12 @@ public class XSLTInputHandler extends InputHandler {
     public XSLTInputHandler(File xmlfile, File xsltfile, Vector params) throws FOPException {
         this.xmlSource  = new StreamSource(xmlfile);
         this.xsltSource = new StreamSource(xsltfile);
+        try {
+            baseURL =
+                new File(xmlfile.getAbsolutePath()).getParentFile().toURL().toExternalForm();
+        } catch (Exception e) {
+            baseURL = "";
+        }
         xsltParams = params;
     }
 
@@ -70,6 +76,12 @@ public class XSLTInputHandler extends InputHandler {
     public XSLTInputHandler(File xmlfile, File xsltfile) throws FOPException {
         this.xmlSource  = new StreamSource(xmlfile);
         this.xsltSource = new StreamSource(xsltfile);
+        try {
+            baseURL =
+                new File(xmlfile.getAbsolutePath()).getParentFile().toURL().toExternalForm();
+        } catch (Exception e) {
+            baseURL = "";
+        }
     }
 
     /**
@@ -144,11 +156,10 @@ public class XSLTInputHandler extends InputHandler {
                     saxTFactory.newXMLFilter(xsltSource);
                     
 /*              if (inParams != null) { 
-                    Transformer transformer = ??? how to obtain from an XMLFilter?
-                    int nParams = inParams.size();
-            
+                    // parameters currently not settable with an XMLFilter
                     for (int i = 0; i < nParams; i += 2) {
-                        transformer.setParameter((String) inParams.elementAt(i),
+                        // setParameter() method doesn't exist
+                        xmlfilter.setParameter((String) inParams.elementAt(i),
                             (String) inParams.elementAt(i + 1));
                     }
                 }
index bf19d3f10d911a0d8ab2b8b364d46d2956378fd7..45aef78c501a4d4748a94e0841444de2fc901d3b 100644 (file)
@@ -219,6 +219,7 @@ public class ImageFactory {
         // Get the absolute URL
         URL absoluteURL = null;
         InputStream in = null;
+
         try {
             in = ua.getStream(href);
         } catch (IOException ioe) {