You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by Thierry SAURA <Th...@renault.fr> on 2001/04/13 10:39:37 UTC

Relative URIS and JDK 1.1 patch

       Hi,

       This patch solves problem with URL class and JDK 1.1 (when you
try to create URL("file:../image.gif")), disables transparency checks for
jdk 1.1 (in GifJpegImage) and handles relative uris in ExternalGraphics.

Comments are welcome about this patch ...

diff -ruN /usr/local/src/fop-0.18.1-dev/src/org/apache/fop/apps/Driver.java org/apache/fop/apps/Driver.java
--- /usr/local/src/fop-0.18.1-dev/src/org/apache/fop/apps/Driver.java	Mon Apr  2 23:15:24 2001
+++ org/apache/fop/apps/Driver.java	Fri Apr 13 10:32:14 2001
@@ -19,6 +19,7 @@
 import org.apache.fop.configuration.Configuration;

 import org.apache.fop.tools.DocumentInputSource;

 import org.apache.fop.tools.DocumentReader;

+import org.apache.fop.tools.URLFactory;

 

 

 // DOM

@@ -36,7 +37,7 @@
 

 // Java

 import java.io.*;

-

+import java.net.MalformedURLException;

 

 /**

  * Primary class that drives overall FOP process.

@@ -393,7 +394,15 @@
                             InputSource source)

 	throws FOPException 

     {

+	String currentURI = source.getSystemId();

 

+	if (currentURI != null) {

+	    try {

+		_treeBuilder.setBaseURI(URLFactory.base(currentURI));

+	    } catch (MalformedURLException e) {

+	    }

+	}

+	

         parser.setContentHandler(_treeBuilder);

         try {

             parser.parse(source);

diff -ruN /usr/local/src/fop-0.18.1-dev/src/org/apache/fop/fo/FOTreeBuilder.java org/apache/fop/fo/FOTreeBuilder.java
--- /usr/local/src/fop-0.18.1-dev/src/org/apache/fop/fo/FOTreeBuilder.java	Mon Apr  2 23:15:35 2001
+++ org/apache/fop/fo/FOTreeBuilder.java	Thu Apr 12 16:30:32 2001
@@ -98,6 +98,11 @@
      */
     protected Hashtable unknownFOs = new Hashtable();
 
+    /**
+     * The base URI when a relative uRI is used
+     */
+    protected String baseURI = null;
+
     // namespace implementation ideas pinched from John Cowan
     //      protected static class NSMap {
     //  	String prefix;
@@ -150,6 +155,14 @@
     //      }
 
     /**
+     * set the base URI
+     * @param String Base URI
+     */
+    public void setBaseURI(String baseURI) {
+	this.baseURI = baseURI;
+    }
+    
+    /**
      * add a mapping from element name to maker.
      *
      * @param namespaceURI namespace URI of formatting object element
@@ -286,6 +299,7 @@
             currentFObj.addChild(fobj);
         }
 
+	fobj.setBaseURI(baseURI);
         currentFObj = fobj;
     }
 
diff -ruN /usr/local/src/fop-0.18.1-dev/src/org/apache/fop/fo/FObj.java org/apache/fop/fo/FObj.java
--- /usr/local/src/fop-0.18.1-dev/src/org/apache/fop/fo/FObj.java	Mon Apr  2 23:15:29 2001
+++ org/apache/fop/fo/FObj.java	Thu Apr 12 16:29:54 2001
@@ -81,6 +81,7 @@
   protected PropertyManager propMgr;
 
   protected String name;
+  protected String baseURI = null;  
 
   protected FObj(FObj parent, PropertyList propertyList) {
     super(parent);
@@ -204,6 +205,12 @@
     this.properties.setWritingMode(p.getProperty("writing-mode").getEnum());
   }
 
-
+    /**
+     * Set Base URI
+     * @param String Base URI
+     */
+    public void setBaseURI(String baseURI) {
+	this.baseURI = baseURI;
+    }
 }
 
diff -ruN /usr/local/src/fop-0.18.1-dev/src/org/apache/fop/fo/flow/ExternalGraphic.java org/apache/fop/fo/flow/ExternalGraphic.java
--- /usr/local/src/fop-0.18.1-dev/src/org/apache/fop/fo/flow/ExternalGraphic.java	Mon Apr  2 23:15:41 2001
+++ org/apache/fop/fo/flow/ExternalGraphic.java	Fri Apr 13 10:24:59 2001
@@ -1,4 +1,4 @@
-/*
+/**
  * ============================================================================
  * The Apache Software License, Version 1.1
  * ============================================================================
@@ -49,6 +49,7 @@
 import org.apache.fop.layout.FontState;
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.image.*;
+import org.apache.fop.tools.URLFactory;
 
 // Java
 import java.util.Enumeration;
@@ -79,7 +80,7 @@
 
 	public Status layout(Area area) throws FOPException {
 
-		if (this.marker == START) {
+	    if (this.marker == START) {
 			// FIXME
 			this.align = this.properties.get("text-align").getEnum();
 
@@ -93,7 +94,10 @@
 			this.spaceAfter = this.properties.get(
 					"space-after.optimum").getLength().mvalue();
 
-			this.src = this.properties.get("src").getString();
+			this.src = URLFactory.
+			    resolveRelativeURI(this.properties.get("src").
+					       getString(),
+					       baseURI);
 
 			this.width = this.properties.get("width").getLength().mvalue();
 
diff -ruN /usr/local/src/fop-0.18.1-dev/src/org/apache/fop/image/FopImageFactory.java org/apache/fop/image/FopImageFactory.java
--- /usr/local/src/fop-0.18.1-dev/src/org/apache/fop/image/FopImageFactory.java	Mon Apr  2 23:15:38 2001
+++ org/apache/fop/image/FopImageFactory.java	Fri Apr 13 10:26:57 2001
@@ -52,6 +52,7 @@
 import org.apache.fop.messaging.MessageHandler;
 import org.apache.fop.image.analyser.ImageReaderFactory;
 import org.apache.fop.image.analyser.ImageReader;
+import org.apache.fop.tools.URLFactory;
 
 /**
  * create FopImage objects (with a configuration file - not yet implemented).
@@ -70,11 +71,10 @@
 	 */
 	public static FopImage Make(String href)
 		throws MalformedURLException, FopImageException {
-
+	    
 		// Get the absolute URL
-		URL absoluteURL = null;
+	        URL absoluteURL = URLFactory.newURL(href);
 		//		try {
-		absoluteURL = new URL(href);
 		/*
 				}
 				catch (MalformedURLException e) {
diff -ruN /usr/local/src/fop-0.18.1-dev/src/org/apache/fop/image/GifJpegImage.java org/apache/fop/image/GifJpegImage.java
--- /usr/local/src/fop-0.18.1-dev/src/org/apache/fop/image/GifJpegImage.java	Mon Apr  2 23:15:27 2001
+++ org/apache/fop/image/GifJpegImage.java	Fri Apr 13 10:27:15 2001
@@ -92,7 +92,9 @@
       this.m_bitsPerPixel = 8;
       //this.m_bitsPerPixel = cm.getPixelSize();
       this.m_colorSpace = new ColorSpace(ColorSpace.DEVICE_RGB);
-      if (cm.hasAlpha()) {
+
+      if ((!System.getProperty("java.version").startsWith("1.1")) &&
+	  cm.hasAlpha()) {
         int transparencyType = cm.getTransparency(); // java.awt.Transparency. BITMASK or OPAQUE or TRANSLUCENT
         if (transparencyType == java.awt.Transparency.OPAQUE) {
           this.m_isTransparent = false;
diff -ruN /usr/local/src/fop-0.18.1-dev/src/org/apache/fop/tools/URLFactory.java org/apache/fop/tools/URLFactory.java
--- /usr/local/src/fop-0.18.1-dev/src/org/apache/fop/tools/URLFactory.java	Thu Jan  1 01:00:00 1970
+++ org/apache/fop/tools/URLFactory.java	Fri Apr 13 08:46:22 2001
@@ -0,0 +1,115 @@
+/**
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ * Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ * 1. Redistributions of  source code must  retain the above copyright  notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include  the following  acknowledgment:  "This product includes  software
+ * developed  by the  Apache Software Foundation  (http://www.apache.org/)."
+ * Alternately, this  acknowledgment may  appear in the software itself,  if
+ * and wherever such third-party acknowledgments normally appear.
+ * 4. The names "FOP" and  "Apache Software Foundation"  must not be used to
+ * endorse  or promote  products derived  from this  software without  prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ * 5. Products  derived from this software may not  be called "Apache", nor may
+ * "Apache" appear  in their name,  without prior written permission  of the
+ * Apache Software Foundation.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
+ * APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
+ * ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
+ * (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * This software  consists of voluntary contributions made  by many individuals
+ * on  behalf of the Apache Software  Foundation and was  originally created by
+ * James Tauber <jt...@jtauber.com>. For more  information on the Apache
+ * Software Foundation, please see <http://www.apache.org/>.
+ */
+
+package org.apache.fop.tools;
+
+import java.net.URL;
+import java.net.MalformedURLException;
+
+/**
+ * Class used to resolve relative uri and jdk 1.1 problems
+ */
+
+public class URLFactory {
+    
+    /**
+     * This method is use to solve a jdk 1.1 problem
+     * new URL("file:../afile.jpg") is understand as file:/file.jpg"
+     * @param String URI
+     * @return URL
+     */
+    public static URL newURL(String uri)
+	throws MalformedURLException {
+	if (uri.startsWith("file:"))
+	    return new URL("file",null,-1,uri.substring(5));
+	else
+	    return new URL(uri); 
+    }
+
+    /**
+     * This method is use to extract base of an URI
+     * @param String uri
+     * @return String base
+     */
+    public static String base(String uri)
+	throws MalformedURLException {
+	URL url = newURL(uri);
+	String file = url.getFile();
+	URL base = new URL(url.getProtocol(),
+			   url.getHost(),
+			   url.getPort(),
+			   file.substring(0,file.lastIndexOf("/")+1));
+	return base.toString();
+    }
+
+    /**
+     * This method checks if uri is relative and append base in this
+     * case
+     * @param String uri
+     * @param String base
+     * @return String uri
+     */
+    public static String resolveRelativeURI(String uri, String base) {
+	if (uri.startsWith("file:") ||
+	    uri.startsWith("ftp:") ||
+	    uri.startsWith("http:")) return uri;
+
+	try {
+	    URL bUrl = new URL(base);
+	    URL url;
+
+	    if (uri.startsWith("/"))
+		url = new URL(bUrl.getProtocol(),
+			      bUrl.getHost(),
+			      bUrl.getPort(),
+			      uri);
+	    else
+		url = new URL(bUrl.getProtocol(),
+			      bUrl.getHost(),
+			      bUrl.getPort(),
+			      bUrl.getFile() + uri);
+
+	    return url.toString();
+	} catch (MalformedURLException e) {
+	}
+
+	return uri;
+    }
+}


Thierry.

AW: AW: Relative URIS and JDK 1.1 patch

Posted by Stephan Kassanke <ka...@upb.de>.
Hi all,

that's the strategy I was having in mind when I approached fop. To me it
seems logical that your document path defines the base for relative
references. In this case you have a system id of the xml file. Ok, this does
not apply if you are working with streams but even in this case setting a
base "image" directory would make sense to me. BTW, does anybody know what
the Driver.SetBase() method does? Alistair mentioned this in a previous post
in this thread. having all relative references relative to the application's
directory mixes data and application together and in y case I want to
generate HTML as well as fop. It would have a lot of advantages for me to
have the *document* path define the base directory.

Generating the absolute URIs dynamically is a solution. The drawback is you
always have to process your document tree before transforming. I have to
admit the straight approach, passing the xml file to fop and getting the
result pdf would suite me better.

Stephan


-----Ursprungliche Nachricht-----
Von: Thierry SAURA [mailto:Thierry.Saura@renault.fr]
Gesendet: Mittwoch, 25. April 2001 14:19
An: Alex McLintock
Cc: fop-dev@xml.apache.org
Betreff: Re: AW: Relative URIS and JDK 1.1 patch



> I remember discussion of it. Basically it is an almost impossible
scenario.
> The relative URL is relative to the starting location of the program which
> is counter intuitive: Hence the recommendation is to use absolute URLs.
Well ... but samples given in fop use relative URIs, it's an example
of the need to have relative URIs. I know that in some cases, we can't
have a base URI because you use fop with an Document for example. My
solution is to decide in this case the way to resolve relative URIs ...
for example, we could decide that the default base URI is the current
directory of the application (which is the current choice).

When you have a base URI, you resolve you relative URI with it (no problem
and very useful). When you don't have a base URI, the base URI is the
current directory of the application.

	sorry if my english is bad :-))) I hope to be enough clear to
be understand ...

Thierry Saura.


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org


Re: AW: Relative URIS and JDK 1.1 patch

Posted by Thierry SAURA <Th...@renault.fr>.
> I remember discussion of it. Basically it is an almost impossible scenario.
> The relative URL is relative to the starting location of the program which 
> is counter intuitive: Hence the recommendation is to use absolute URLs.
Well ... but samples given in fop use relative URIs, it's an example
of the need to have relative URIs. I know that in some cases, we can't
have a base URI because you use fop with an Document for example. My
solution is to decide in this case the way to resolve relative URIs ...
for example, we could decide that the default base URI is the current
directory of the application (which is the current choice).

When you have a base URI, you resolve you relative URI with it (no problem
and very useful). When you don't have a base URI, the base URI is the
current directory of the application.

	sorry if my english is bad :-))) I hope to be enough clear to
be understand ...

Thierry Saura.


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org


Re: AW: Relative URIS and JDK 1.1 patch

Posted by Alex McLintock <al...@yahoo.com>.
--- Stephan Kassanke <ka...@upb.de> wrote: 
> Dear Thierry and dear members of the fop-dev list,
> 
> I am not sure how the cvs really works. is everybody allowed to commit
> changes or is there some kind of check before committing changes to the cvs
> source tree to avoid side effects, etc? 


The roles within the Apache organisation are quite well defined and so is
the way it uses CVS.

Try looking at the Apache Jakarta website 
(http://jakarta.apache.org/site/getinvolved.html and
http://jakarta.apache.org/site/guidelines.html)

I know fop is an Apache XML project but these docs still apply.


> What really surprises me is that apparently  rarely anybody came across this
> problem (relative URIs for images in the context of embedding fop into a
> servlet or java application) before.

I remember discussion of it. Basically it is an almost impossible scenario.
The relative URL is relative to the starting location of the program which 
is counter intuitive: Hence the recommendation is to use absolute URLs.

If you can come up with a well defined way of dealing with this so that it is clear
and unambiguous then I expect that people will help you submit patches.



Alex

=====
Alex McLintock        alex@OWAL.co.uk
OpenWeb Analysts Ltd, http://www.OWAL.co.uk/ 
Software for Complex Websites.
Publisher of http://www.DiverseBooks.com
Get Your XML T-Shirt <t-shirt/> at http://www.inversity.co.uk/

____________________________________________________________
Do You Yahoo!?
Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk
or your free @yahoo.ie address at http://mail.yahoo.ie

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org


AW: Relative URIS and JDK 1.1 patch

Posted by Stephan Kassanke <ka...@upb.de>.
Dear Thierry and dear members of the fop-dev list,

I am not sure how the cvs really works. is everybody allowed to commit
changes or is there some kind of check before committing changes to the cvs
source tree to avoid side effects, etc? Otherwise I would propose you submit
your changes to the cvs. I am very new to the open source scene and I am not
sure how the mechanisms work in such a seting. Maybe somebody can point me
to some internet resources on this issue.

What really surprises me is that apparently  rarely anybody came across this
problem (relative URIs for images in the context of embedding fop into a
servlet or java application) before. In my scenarion embedding images into a
document is a quite frequent task and using absolute URIs is absolutely no
solution at all. On the other side I have to admit that I cannot contribute
very much to the source code of fop because i am really not that experienced
in programming in Java and the probability to harm the existing code is
pretty high in my case... Anyway, i see my role more in using and testing
fop and pointing out existing difficulties. Some may call this selfish but
errors have to known before they can be corrected, right?

Stephan


--------------
Stephan Kassanke, University of Paderborn,
work: 	http://dsor.uni-paderborn.de
project:	http://www.or-world.com


-----Ursprungliche Nachricht-----
Von: Thierry SAURA [mailto:Thierry.Saura@renault.fr]
Gesendet: Dienstag, 24. April 2001 13:34
An: Stephan Kassanke
Cc: fop-dev@xml.apache.org
Betreff: AW: Relative URIS and JDK 1.1 patch



       Stephan,

       The only solution is to use absolute URIs which isn't a
good solution when you are in a servlet context ... my patch is a solution
among others, how can we work to design the best way to implemant relative
URIs ?

Thierry.


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org


AW: Relative URIS and JDK 1.1 patch

Posted by Thierry SAURA <Th...@renault.fr>.
       Stephan,

       The only solution is to use absolute URIs which isn't a
good solution when you are in a servlet context ... my patch is a solution
among others, how can we work to design the best way to implemant relative
URIs ? 

Thierry.


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org


AW: Relative URIS and JDK 1.1 patch

Posted by Stephan Kassanke <ka...@upb.de>.
Thierry,

sorry for the delay, i've been away for a while. Honestly speaking I am not
the guy to put my hands on the actual fop code and introduce patches like
the one you proposed. My question is: Is the problem with external graphics
and relative URLs known and is this going to be resolved in the next
version. How do you currently get along with this, hard coding the image's
URIs?

Stephan

--------------
Stephan Kassanke, University of Paderborn, Decision Support & OR Lab, Room
N5.125, Warburger Stra?e 100, 33095 Paderborn, Germany, phone: +49 (0)5251
602416, fax:   +49 (0)5251 603542, mobile:+49 (0)171 8984868, mail:
kass@uni-paderborn.de, ICQ:   16285877
work: 	http://dsor.uni-paderborn.de
project:	http://www.or-world.com
private:	http://www.kassanke.de


-----Ursprungliche Nachricht-----
Von: Thierry SAURA [mailto:Thierry.Saura@renault.fr]
Gesendet: Freitag, 13. April 2001 10:40
An: fop-dev@xml.apache.org
Betreff: Relative URIS and JDK 1.1 patch



       Hi,

       This patch solves problem with URL class and JDK 1.1 (when you
try to create URL("file:../image.gif")), disables transparency checks for
jdk 1.1 (in GifJpegImage) and handles relative uris in ExternalGraphics.

Comments are welcome about this patch ...

diff -ruN /usr/local/src/fop-0.18.1-dev/src/org/apache/fop/apps/Driver.java
org/apache/fop/apps/Driver.java
--- /usr/local/src/fop-0.18.1-dev/src/org/apache/fop/apps/Driver.java	Mon
Apr  2 23:15:24 2001
+++ org/apache/fop/apps/Driver.java	Fri Apr 13 10:32:14 2001
@@ -19,6 +19,7 @@
 import org.apache.fop.configuration.Configuration;  import
org.apache.fop.tools.DocumentInputSource;  import
org.apache.fop.tools.DocumentReader; +import
org.apache.fop.tools.URLFactory;      // DOM @@ -36,7 +37,7 @@
   // Java  import java.io.*; - +import java.net.MalformedURLException;
/**   * Primary class that drives overall FOP process. @@ -393,7 +394,15 @@
                             InputSource source)  	throws FOPException
{ +	String currentURI = source.getSystemId();   +	if (currentURI != null)
 +	    try { +		_treeBuilder.setBaseURI(URLFactory.base(currentURI));
  } catch (MalformedURLException e) { +	    } +	} +
parser.setContentHandler(_treeBuilder);          try
 parser.parse(source); diff -ruN
/usr/local/src/fop-0.18.1-dev/src/org/apache/fop/fo/FOTreeBuilder.java
org/apache/fop/fo/FOTreeBuilder.java
--- /usr/local/src/fop-0.18.1-dev/src/org/apache/fop/fo/FOTreeBuilder.java
Mon Apr  2 23:15:35 2001
+++ org/apache/fop/fo/FOTreeBuilder.java	Thu Apr 12 16:30:32 2001
@@ -98,6 +98,11 @@
      */
     protected Hashtable unknownFOs = new Hashtable();

+    /**
+     * The base URI when a relative uRI is used
+     */
+    protected String baseURI = null;
+
     // namespace implementation ideas pinched from John Cowan
     //      protected static class NSMap {
     //  	String prefix;
@@ -150,6 +155,14 @@
     //      }

     /**
+     * set the base URI
+     * @param String Base URI
+     */
+    public void setBaseURI(String baseURI) {
+	this.baseURI = baseURI;
+    }
+
+    /**
      * add a mapping from element name to maker.
      *
      * @param namespaceURI namespace URI of formatting object element
@@ -286,6 +299,7 @@
             currentFObj.addChild(fobj);
         }

+	fobj.setBaseURI(baseURI);
         currentFObj = fobj;
     }

diff -ruN /usr/local/src/fop-0.18.1-dev/src/org/apache/fop/fo/FObj.java
org/apache/fop/fo/FObj.java
--- /usr/local/src/fop-0.18.1-dev/src/org/apache/fop/fo/FObj.java	Mon Apr  2
23:15:29 2001
+++ org/apache/fop/fo/FObj.java	Thu Apr 12 16:29:54 2001
@@ -81,6 +81,7 @@
   protected PropertyManager propMgr;

   protected String name;
+  protected String baseURI = null;

   protected FObj(FObj parent, PropertyList propertyList) {
     super(parent);
@@ -204,6 +205,12 @@

this.properties.setWritingMode(p.getProperty("writing-mode").getEnum());
   }

-
+    /**
+     * Set Base URI
+     * @param String Base URI
+     */
+    public void setBaseURI(String baseURI) {
+	this.baseURI = baseURI;
+    }
 }

diff -ruN
/usr/local/src/fop-0.18.1-dev/src/org/apache/fop/fo/flow/ExternalGraphic.jav
a org/apache/fop/fo/flow/ExternalGraphic.java
---
/usr/local/src/fop-0.18.1-dev/src/org/apache/fop/fo/flow/ExternalGraphic.jav
a	Mon Apr  2 23:15:41 2001
+++ org/apache/fop/fo/flow/ExternalGraphic.java	Fri Apr 13 10:24:59 2001
@@ -1,4 +1,4 @@
-/*
+/**
  *
============================================================================
  * The Apache Software License, Version 1.1
  *
============================================================================
@@ -49,6 +49,7 @@
 import org.apache.fop.layout.FontState;
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.image.*;
+import org.apache.fop.tools.URLFactory;

 // Java
 import java.util.Enumeration;
@@ -79,7 +80,7 @@

 	public Status layout(Area area) throws FOPException {

-		if (this.marker == START) {
+	    if (this.marker == START) {
 			// FIXME
 			this.align = this.properties.get("text-align").getEnum();

@@ -93,7 +94,10 @@
 			this.spaceAfter = this.properties.get(
 					"space-after.optimum").getLength().mvalue();

-			this.src = this.properties.get("src").getString();
+			this.src = URLFactory.
+			    resolveRelativeURI(this.properties.get("src").
+					       getString(),
+					       baseURI);

 			this.width = this.properties.get("width").getLength().mvalue();

diff -ruN
/usr/local/src/fop-0.18.1-dev/src/org/apache/fop/image/FopImageFactory.java
org/apache/fop/image/FopImageFactory.java
---
/usr/local/src/fop-0.18.1-dev/src/org/apache/fop/image/FopImageFactory.java
Mon Apr  2 23:15:38 2001
+++ org/apache/fop/image/FopImageFactory.java	Fri Apr 13 10:26:57 2001
@@ -52,6 +52,7 @@
 import org.apache.fop.messaging.MessageHandler;
 import org.apache.fop.image.analyser.ImageReaderFactory;
 import org.apache.fop.image.analyser.ImageReader;
+import org.apache.fop.tools.URLFactory;

 /**
  * create FopImage objects (with a configuration file - not yet
implemented).
@@ -70,11 +71,10 @@
 	 */
 	public static FopImage Make(String href)
 		throws MalformedURLException, FopImageException {
-
+
 		// Get the absolute URL
-		URL absoluteURL = null;
+	        URL absoluteURL = URLFactory.newURL(href);
 		//		try {
-		absoluteURL = new URL(href);
 		/*
 				}
 				catch (MalformedURLException e) {
diff -ruN
/usr/local/src/fop-0.18.1-dev/src/org/apache/fop/image/GifJpegImage.java
org/apache/fop/image/GifJpegImage.java
--- /usr/local/src/fop-0.18.1-dev/src/org/apache/fop/image/GifJpegImage.java
Mon Apr  2 23:15:27 2001
+++ org/apache/fop/image/GifJpegImage.java	Fri Apr 13 10:27:15 2001
@@ -92,7 +92,9 @@
       this.m_bitsPerPixel = 8;
       //this.m_bitsPerPixel = cm.getPixelSize();
       this.m_colorSpace = new ColorSpace(ColorSpace.DEVICE_RGB);
-      if (cm.hasAlpha()) {
+
+      if ((!System.getProperty("java.version").startsWith("1.1")) &&
+	  cm.hasAlpha()) {
         int transparencyType = cm.getTransparency(); //
java.awt.Transparency. BITMASK or OPAQUE or TRANSLUCENT
         if (transparencyType == java.awt.Transparency.OPAQUE) {
           this.m_isTransparent = false;
diff -ruN
/usr/local/src/fop-0.18.1-dev/src/org/apache/fop/tools/URLFactory.java
org/apache/fop/tools/URLFactory.java
--- /usr/local/src/fop-0.18.1-dev/src/org/apache/fop/tools/URLFactory.java
Thu Jan  1 01:00:00 1970
+++ org/apache/fop/tools/URLFactory.java	Fri Apr 13 08:46:22 2001
@@ -0,0 +1,115 @@
+/**
+ *
============================================================================
+ * The Apache Software License, Version 1.1
+ *
============================================================================
+ * Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
+ * Redistribution and use in source and binary forms, with or without
modifica-
+ * tion, are permitted provided that the following conditions are met:
+ * 1. Redistributions of  source code must  retain the above copyright
notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
notice,
+ * this list of conditions and the following disclaimer in the
documentation
+ * and/or other materials provided with the distribution.
+ * 3. The end-user documentation included with the redistribution, if any,
must
+ * include  the following  acknowledgment:  "This product includes
software
+ * developed  by the  Apache Software Foundation
(http://www.apache.org/)."
+ * Alternately, this  acknowledgment may  appear in the software itself,
if
+ * and wherever such third-party acknowledgments normally appear.
+ * 4. The names "FOP" and  "Apache Software Foundation"  must not be used
to
+ * endorse  or promote  products derived  from this  software without
prior
+ * written permission. For written permission, please contact
+ * apache@apache.org.
+ * 5. Products  derived from this software may not  be called "Apache", nor
may
+ * "Apache" appear  in their name,  without prior written permission  of
the
+ * Apache Software Foundation.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND
+ * FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL
THE
+ * APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY
DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES
(INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES;
LOSS
+ * OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED
AND ON
+ * ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR
TORT
+ * (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE
USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * This software  consists of voluntary contributions made  by many
individuals
+ * on  behalf of the Apache Software  Foundation and was  originally
created by
+ * James Tauber <jt...@jtauber.com>. For more  information on the Apache
+ * Software Foundation, please see <http://www.apache.org/>.
+ */
+
+package org.apache.fop.tools;
+
+import java.net.URL;
+import java.net.MalformedURLException;
+
+/**
+ * Class used to resolve relative uri and jdk 1.1 problems
+ */
+
+public class URLFactory {
+
+    /**
+     * This method is use to solve a jdk 1.1 problem
+     * new URL("file:../afile.jpg") is understand as file:/file.jpg"
+     * @param String URI
+     * @return URL
+     */
+    public static URL newURL(String uri)
+	throws MalformedURLException {
+	if (uri.startsWith("file:"))
+	    return new URL("file",null,-1,uri.substring(5));
+	else
+	    return new URL(uri);
+    }
+
+    /**
+     * This method is use to extract base of an URI
+     * @param String uri
+     * @return String base
+     */
+    public static String base(String uri)
+	throws MalformedURLException {
+	URL url = newURL(uri);
+	String file = url.getFile();
+	URL base = new URL(url.getProtocol(),
+			   url.getHost(),
+			   url.getPort(),
+			   file.substring(0,file.lastIndexOf("/")+1));
+	return base.toString();
+    }
+
+    /**
+     * This method checks if uri is relative and append base in this
+     * case
+     * @param String uri
+     * @param String base
+     * @return String uri
+     */
+    public static String resolveRelativeURI(String uri, String base) {
+	if (uri.startsWith("file:") ||
+	    uri.startsWith("ftp:") ||
+	    uri.startsWith("http:")) return uri;
+
+	try {
+	    URL bUrl = new URL(base);
+	    URL url;
+
+	    if (uri.startsWith("/"))
+		url = new URL(bUrl.getProtocol(),
+			      bUrl.getHost(),
+			      bUrl.getPort(),
+			      uri);
+	    else
+		url = new URL(bUrl.getProtocol(),
+			      bUrl.getHost(),
+			      bUrl.getPort(),
+			      bUrl.getFile() + uri);
+
+	    return url.toString();
+	} catch (MalformedURLException e) {
+	}
+
+	return uri;
+    }
+}


Thierry.


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org