cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Avi Kivity <...@argo.co.il>
Subject [PATCH] Allow XIncludeTransformer to include absolute URLs
Date Tue, 30 Apr 2002 12:15:41 GMT
--- XIncludeTransformer.java.orig
+++ src/java/org/apache/cocoon/transformation/XIncludeTransformer.java
@@ -74,6 +74,7 @@
  import java.net.MalformedURLException;
  import java.util.Map;
  import java.util.Stack;
+import java.net.URL;

  /**
   * My first pass at an XInclude transformation. Currently it should 
set the base URI
@@ -85,7 +86,7 @@
   * @author <a href="mailto:balld@webslingerZ.com">Donald Ball</a>
   * @version CVS $Id: XIncludeTransformer.java,v 1.11 2002/03/13 
16:28:02 cziegeler Exp $
   */
-public class XIncludeTransformer_Old extends AbstractTransformer 
implements Composable, Disposable {
+public class XIncludeTransformer extends AbstractTransformer implements 
Composable, Disposable {

      private SourceResolver resolver;

@@ -255,22 +256,21 @@
          }

          Source url = null;
-        String suffix;
+        String base, suffix;
          try {
              int index = href.indexOf('#');
              if (index < 0) {
-                if(current_xmlbase_uri == null)
-                    url = this.resolver.resolve(href);
-                else
-                    url = 
this.resolver.resolve(current_xmlbase_uri.getSystemId() + href);
+                base = href;
                  suffix = "";
              } else {
-                if(current_xmlbase_uri == null)
-                    url = this.resolver.resolve(href.substring(0,index));
-                else
-                    url = 
this.resolver.resolve(current_xmlbase_uri.getSystemId() + 
href.substring(0,index));
+                base = href.substring(0, index);
                  suffix = href.substring(index+1);
              }
+            if(current_xmlbase_uri != null) {
+                URL context = new URL(current_xmlbase_uri.getSystemId());
+                base = new URL(context, base).toString();
+            }
+            url = this.resolver.resolve(base);
              if (getLogger().isDebugEnabled()) {
                  getLogger().debug("URL: "+url+"\nSuffix: "+suffix);
              }
~/cocoon/2.0.2>
-- 
This space for rent.


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


Mime
View raw message