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 2002/07/01 02:05:16 UTC

cvs commit: xml-cocoon2/src/java/org/apache/cocoon/components/xslt XSLTProcessorImpl.java

vgritsenko    2002/06/30 17:05:16

  Modified:    src/java/org/apache/cocoon/components/xslt Tag:
                        cocoon_2_0_3_branch XSLTProcessorImpl.java
  Log:
  "Fix" bug 10244: Log when something goes wrong.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.18.2.3  +28 -11    xml-cocoon2/src/java/org/apache/cocoon/components/xslt/XSLTProcessorImpl.java
  
  Index: XSLTProcessorImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/xslt/XSLTProcessorImpl.java,v
  retrieving revision 1.18.2.2
  retrieving revision 1.18.2.3
  diff -u -r1.18.2.2 -r1.18.2.3
  --- XSLTProcessorImpl.java	29 Jun 2002 00:40:34 -0000	1.18.2.2
  +++ XSLTProcessorImpl.java	1 Jul 2002 00:05:16 -0000	1.18.2.3
  @@ -86,6 +86,8 @@
   import javax.xml.transform.stream.StreamSource;
   import java.io.File;
   import java.io.IOException;
  +import java.net.MalformedURLException;
  +import java.net.URL;
   import java.util.List;
   import java.util.ArrayList;
   
  @@ -143,7 +145,7 @@
       /** Is incremental processing turned on? (default for Xalan: no) */
       protected boolean incrementalProcessing = false;
   
  -    /** Resolver used to resolve XSL includes */
  +    /** Resolver used to resolve XSLT document() calls, imports and includes */
       protected SourceResolver resolver;
   
       /** List accumulating included stylesheets */
  @@ -455,13 +457,13 @@
   
           Source xslSource = null;
           try {
  -            if (href.indexOf(":") > 1) {
  +            if (base == null || href.indexOf(":") > 1) {
  +                // Null base - href must be an absolute
                   xslSource = resolver.resolve(href);
  +            } else if (href.length() == 0) {
  +                // Empty href resolves to base
  +                xslSource = resolver.resolve(base);
               } else {
  -                // patch for a null pointer passed as base
  -                if (base == null)
  -                    throw new IllegalArgumentException("Null pointer passed as base");
  -
                   // is the base a file or a real url
                   if (!base.startsWith("file:")) {
                       int lastPathElementPos = base.lastIndexOf('/');
  @@ -470,8 +472,8 @@
                           // always be protocol:/....
                           return null; // we can't resolve this
                       } else {
  -                        xslSource = resolver.resolve(new StringBuffer(base.substring(0, lastPathElementPos))
  -                        .append("/").append(href).toString());
  +                        xslSource = resolver.resolve(
  +                            base.substring(0, lastPathElementPos) + "/" + href);
                       }
                   } else {
                       File parent = new File(base.substring(5));
  @@ -491,12 +493,27 @@
               }
               return new StreamSource(is.getByteStream(), is.getSystemId());
           } catch (ResourceNotFoundException rnfe) {
  -            // to obtain the same behaviour as when the resource is
  +            if (getLogger().isDebugEnabled()) {
  +                getLogger().debug("Failed to resolve " + href
  +                    + "(base = " + base + "), return null", rnfe);
  +            }
  +
  +            // CZ: To obtain the same behaviour as when the resource is
               // transformed by the XSLT Transformer we should return null here.
               return null;
  -        } catch (java.net.MalformedURLException mue) {
  +        } catch (MalformedURLException mue) {
  +            if (getLogger().isDebugEnabled()) {
  +                getLogger().debug("Failed to resolve " + href
  +                    + "(base = " + base + "), return null", mue);
  +            }
  +            
               return null;
           } catch (IOException ioe) {
  +            if (getLogger().isDebugEnabled()) {
  +                getLogger().debug("Failed to resolve " + href
  +                    + "(base = " + base + "), return null", ioe);
  +            }
  +
               return null;
           } catch (SAXException se) {
               throw new TransformerException(se);
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org