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/09/04 12:03:20 UTC

svn commit: r440004 - in /cocoon/branches/BRANCH_2_1_X: src/blocks/xsp/samples/logicsheets/interpolation.xsl src/java/org/apache/cocoon/components/xslt/TraxProcessor.java status.xml

Author: anathaniel
Date: Mon Sep  4 03:03:19 2006
New Revision: 440004

URL: http://svn.apache.org/viewvc?view=rev&rev=440004
Log:
XSP block: Using document('') in logicsheet caused NPE.

Modified:
    cocoon/branches/BRANCH_2_1_X/src/blocks/xsp/samples/logicsheets/interpolation.xsl
    cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/xslt/TraxProcessor.java
    cocoon/branches/BRANCH_2_1_X/status.xml

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/xsp/samples/logicsheets/interpolation.xsl
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/xsp/samples/logicsheets/interpolation.xsl?view=diff&rev=440004&r1=440003&r2=440004
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/xsp/samples/logicsheets/interpolation.xsl (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/xsp/samples/logicsheets/interpolation.xsl Mon Sep  4 03:03:19 2006
@@ -31,8 +31,14 @@
   <xsl:template match="xsp-interpolation:greeting">
     <!-- Using attribute and text interpolation. -->
     <center style="color:{#color}">Hello logicsheet {#world}!</center>
+    <!-- Testcase for document('') in logicsheet. -->
+    <center style="color:{#color}">
+      <xsl:copy-of select="document('')/*/xsp-interpolation:hello"/> {#world}!
+    </center>
   </xsl:template>
- 
+
+  <xsp-interpolation:hello>Hello document </xsp-interpolation:hello>
+  
   <xsl:template match="@*|*|text()|processing-instruction()">
     <xsl:copy>
       <xsl:apply-templates select="@*|*|text()|processing-instruction()"/>

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/xslt/TraxProcessor.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/xslt/TraxProcessor.java?view=diff&rev=440004&r1=440003&r2=440004
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/xslt/TraxProcessor.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/xslt/TraxProcessor.java Mon Sep  4 03:03:19 2006
@@ -19,6 +19,7 @@
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
+import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -247,6 +248,14 @@
                     throw new XSLTProcessorException("Unable to create templates for stylesheet: " + stylesheet.getURI());
                 }
 
+                // Must set base for Xalan stylesheet.
+                // Otherwise document('') in logicsheet causes NPE.
+                Class clazz = template.getClass();
+                if (clazz.getName().equals("org.apache.xalan.templates.StylesheetRoot")) {
+               	    Method method = clazz.getMethod("setHref", new Class[]{String.class});
+               	    method.invoke(template, new Object[]{id});
+                }
+                
                 putTemplates(template, stylesheet, id);
 
                 // Create transformer handler

Modified: cocoon/branches/BRANCH_2_1_X/status.xml
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/status.xml?view=diff&rev=440004&r1=440003&r2=440004
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/status.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/status.xml Mon Sep  4 03:03:19 2006
@@ -184,6 +184,9 @@
   <release version="@version@" date="@date@">
 -->
   <release version="2.1.10" date="TBD">
+    <action dev="AN" type="fix">
+      XSP block: Using document('') in logicsheet caused NPE.
+    </action>
     <action dev="VG" type="fix">
       CForms: Repeater identity binding was failing on save if widget path was
       given.