You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by an...@apache.org on 2006/05/29 08:47:54 UTC

svn commit: r410030 - in /cocoon/branches/BRANCH_2_1_X: ./ src/java/org/apache/cocoon/transformation/ src/test/org/apache/cocoon/transformation/

Author: antonio
Date: Sun May 28 23:47:54 2006
New Revision: 410030

URL: http://svn.apache.org/viewvc?rev=410030&view=rev
Log:
Fix COCOON-1110 xi:fallback fail when use parse='text'.

Added:
    cocoon/branches/BRANCH_2_1_X/src/test/org/apache/cocoon/transformation/xinclude-input-simpleFallbackForTextParseTest.xml   (with props)
Modified:
    cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/XIncludeTransformer.java
    cocoon/branches/BRANCH_2_1_X/src/test/org/apache/cocoon/transformation/XIncludeTransformerTestCase.java
    cocoon/branches/BRANCH_2_1_X/status.xml

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/XIncludeTransformer.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/XIncludeTransformer.java?rev=410030&r1=410029&r2=410030&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/XIncludeTransformer.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/XIncludeTransformer.java Sun May 28 23:47:54 2006
@@ -46,6 +46,7 @@
 import org.apache.cocoon.xml.XMLConsumer;
 import org.apache.excalibur.source.Source;
 import org.apache.excalibur.source.SourceException;
+import org.apache.excalibur.source.SourceNotFoundException;
 import org.apache.excalibur.source.SourceValidity; 
 import org.xml.sax.Attributes;
 import org.xml.sax.ContentHandler;
@@ -440,6 +441,10 @@
                         while ((read = reader.read(ary)) != -1) {
                             super.characters(ary,0,read);
                         }
+                    } catch (SourceNotFoundException e) {
+                        useFallback = true;
+                        fallBackException = new CascadingException("Resource not found: " + url.getURI());
+                        getLogger().error("xIncluded resource not found: " + url.getURI(), e);
                     } finally {
                         if (reader != null) reader.close();
                         if (isr != null) isr.close();

Modified: cocoon/branches/BRANCH_2_1_X/src/test/org/apache/cocoon/transformation/XIncludeTransformerTestCase.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/test/org/apache/cocoon/transformation/XIncludeTransformerTestCase.java?rev=410030&r1=410029&r2=410030&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/test/org/apache/cocoon/transformation/XIncludeTransformerTestCase.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/test/org/apache/cocoon/transformation/XIncludeTransformerTestCase.java Sun May 28 23:47:54 2006
@@ -91,24 +91,37 @@
         xincludeTest("resource://org/apache/cocoon/transformation/xinclude-input-2.xml",
                 "resource://org/apache/cocoon/transformation/xinclude-result-2.xml");
     }
-    
+
     /** Testcase for xinclude simple fallback
-    *
-    * @throws Exception if ComponentManager enterEnvironment fails
-    */
-   public void testXIncludeSimpleFallbackTest() throws Exception {
-       getLogger().debug("testXIncludeSimpleFallbackTest");
+     * Check issue: COCOON-1489
+     *
+     * @throws Exception if ComponentManager enterEnvironment fails
+     */
+   public void testXIncludeSimpleFallback() throws Exception {
+       getLogger().debug("testXIncludeSimpleFallback");
        xincludeTest("resource://org/apache/cocoon/transformation/xinclude-input-fallbackTest.xml",
                "resource://org/apache/cocoon/transformation/xinclude-result-fallbackTest.xml");
    }
-   
+
    /** Testcase for xinclude with a nested xinclude elemento into the fallback
+    * Check issue: COCOON-1489
+    *
+    * @throws Exception if ComponentManager enterEnvironment fails
+    */
+  public void testXIncludeNestedXincludeElementInAFallback() throws Exception {
+      getLogger().debug("testXIncludeNestedXincludeElementInAFallback");
+      xincludeTest("resource://org/apache/cocoon/transformation/xinclude-input-nestedXincludeFallbackTest.xml",
+              "resource://org/apache/cocoon/transformation/xinclude-result-fallbackTest.xml");
+  }
+
+  /** Testcase for xinclude simple fallback when parse attribute is 'text'
+   *  Check issue: COCOON-1110 
    *
    * @throws Exception if ComponentManager enterEnvironment fails
    */
-  public void testXIncludeNestedXincludeElementInAFallbackTest() throws Exception {
-      getLogger().debug("testXIncludeNestedXincludeElementInAFallbackTest");
-      xincludeTest("resource://org/apache/cocoon/transformation/xinclude-input-nestedXincludeFallbackTest.xml",
+  public void testXIncludeSimpleFallbackForTextParse() throws Exception {
+      getLogger().debug("testXIncludeSimpleFallbackForTextParse");
+      xincludeTest("resource://org/apache/cocoon/transformation/xinclude-input-simpleFallbackForTextParseTest.xml",
               "resource://org/apache/cocoon/transformation/xinclude-result-fallbackTest.xml");
   }
 }

Added: cocoon/branches/BRANCH_2_1_X/src/test/org/apache/cocoon/transformation/xinclude-input-simpleFallbackForTextParseTest.xml
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/test/org/apache/cocoon/transformation/xinclude-input-simpleFallbackForTextParseTest.xml?rev=410030&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/test/org/apache/cocoon/transformation/xinclude-input-simpleFallbackForTextParseTest.xml (added)
+++ cocoon/branches/BRANCH_2_1_X/src/test/org/apache/cocoon/transformation/xinclude-input-simpleFallbackForTextParseTest.xml Sun May 28 23:47:54 2006
@@ -0,0 +1,31 @@
+<?xml version="1.0" ?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<root
+  xmlns:xi="http://www.w3.org/2001/XInclude">
+  <p>P1</p>
+  <p>P2</p>
+
+  <xi:include parse="text" href="this_file_does_not_exist.txt">
+    <xi:fallback>
+      <element>This should be here if the file was not found</element>
+    </xi:fallback>
+  </xi:include> 
+
+  <p>P3</p>
+  <p>P4</p>
+</root>
\ No newline at end of file

Propchange: cocoon/branches/BRANCH_2_1_X/src/test/org/apache/cocoon/transformation/xinclude-input-simpleFallbackForTextParseTest.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: cocoon/branches/BRANCH_2_1_X/status.xml
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/status.xml?rev=410030&r1=410029&r2=410030&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/status.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/status.xml Sun May 28 23:47:54 2006
@@ -182,6 +182,9 @@
   <release version="@version@" date="@date@">
 -->
   <release version="2.1.10" date="TBD">
+    <action dev="AG" type="add" fixes-bug="COCOON-1110">
+      XIncludeTransformer: xi:fallback fail when use parse="text".
+    </action>
     <action dev="AG" type="add" fixes-bug="COCOON-1753" due-to="Jason Johnston" due-to-email="cocoon@lojjic.net">
       XInclude transformer uses href fragment rather than xpointer attribute (spec conformance).
       The XInclude 1.0 spec (see http://www.w3.org/TR/xinclude/#include_element) states the following