Index: src/org/apache/cocoon/components/language/markup/sitemap/java/sitemap.xsl
===================================================================
RCS file: /home/cvspublic/xml-cocoon2/src/org/apache/cocoon/components/language/markup/sitemap/java/sitemap.xsl,v
retrieving revision 1.23
diff -u -r1.23 sitemap.xsl
--- src/org/apache/cocoon/components/language/markup/sitemap/java/sitemap.xsl	2001/06/28 10:48:33	1.23
+++ src/org/apache/cocoon/components/language/markup/sitemap/java/sitemap.xsl	2001/06/29 13:29:11
@@ -431,6 +445,21 @@
           if(pipeline != null)
             this.manager.release(pipeline);
         }
+        <xsl:if test="/map:sitemap/map:pipelines/map:handle-errors">
+        if (!result) {
+            getLogger().warn("Error, try to process the error page, because 'resource-not-found'");
+            try {
+               return error_process_nan(environment, 
+                       environment.getObjectModel(), 
+                       new ResourceNotFoundException("The requested URI '"
+                             + environment.getURI())
+                             + "' was not found."), false);
+            } catch (Exception ex) {
+               getLogger().warn("Sitemap Error Process", ex);
+            }   
+        }        
+        </xsl:if>
+
         return result;
       }
 
@@ -479,9 +508,9 @@
             </xsl:for-each>
           } catch (ConnectionResetException cre) {
             getLogger().debug("Connection reset by peer");
-          } catch (ResourceNotFoundException rse) {
-            getLogger().warn("404 Resource Not Found", rse);
-            throw rse;
+//          } catch (ResourceNotFoundException rse) {
+//            getLogger().warn("404 Resource Not Found", rse);
+//            throw rse;
           } catch (Exception e) {
             <xsl:choose>
               <xsl:when test="(./map:handle-errors)">
@@ -510,10 +539,27 @@
 
       <!-- generate methods for every map:handle-errors elements in all map:pipeline elements -->
       <xsl:for-each select="/map:sitemap/map:pipelines/map:pipeline">
+        <xsl:variable name="pipeline-position" select="position()"/>      
         <xsl:call-template name="line-number"/>
-        <xsl:variable name="pipeline-position" select="position()"/>
         <xsl:apply-templates select="./*"/>
-        <xsl:if test="(./map:handle-errors)">
+        <xsl:for-each select="(./map:handle-errors)">        
+         <xsl:call-template name="error-process">
+          <xsl:with-param name="pipeline-position" select="$pipeline-position"/>
+         </xsl:call-template>
+        </xsl:for-each>          
+      </xsl:for-each>
+      
+      <xsl:for-each select="/map:sitemap/map:pipelines/map:handle-errors">
+        <xsl:call-template name="line-number"/>
+        <xsl:call-template name="error-process">
+         <xsl:with-param name="pipeline-position">nan</xsl:with-param>
+        </xsl:call-template>        
+      </xsl:for-each>
+    }
+  </xsl:template> <!-- match="map:sitemap" -->
+
+  <xsl:template name="error-process">      
+     <xsl:param name="pipeline-position" select="position()"/>
           private boolean error_process_<xsl:value-of select="$pipeline-position"/> (Environment environment, Map objectModel, Exception e, boolean internalRequest)
           throws Exception {
             EventPipeline eventPipeline = null;
@@ -526,11 +572,11 @@
               Map map;
               Parameters param;
               eventPipeline.setGenerator ("!error-notifier!", e.getMessage(), emptyParam, e);
-              <xsl:apply-templates select="./map:handle-errors/*"/>
+              <xsl:apply-templates select="./*"/>
             } catch (Exception ex) {
               getLogger().error("error notifier barfs", ex);
               throw e;
-            } finally {
+            } finally { 
               if(eventPipeline != null)
                 this.manager.release(eventPipeline);
               if(pipeline != null)
@@ -538,9 +584,6 @@
             }
             return false;
           }
-        </xsl:if>
-      </xsl:for-each>
-    }
   </xsl:template> <!-- match="map:sitemap" -->
 
   <!-- a match element calls a match method on a matcher component (or a inlined

