cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vgritse...@apache.org
Subject svn commit: rev 55767 - in cocoon/trunk: . src/blocks/python/java/org/apache/cocoon/components/language/markup/xsp/python src/blocks/xsp/java/org/apache/cocoon/components/language/markup/xsp/java src/blocks/xsp/java/org/apache/cocoon/components/language/markup/xsp/javascript src/blocks/xsp/samples src/blocks/xsp/samples/java src/blocks/xsp/samples/javascript src/blocks/xsp/samples/python
Date Thu, 28 Oct 2004 02:38:37 GMT
Author: vgritsenko
Date: Wed Oct 27 19:38:37 2004
New Revision: 55767

Added:
   cocoon/trunk/src/blocks/xsp/samples/java/stripped.xsp   (props changed)
      - copied unchanged from rev 55766, cocoon/branches/BRANCH_2_1_X/src/blocks/xsp/samples/java/stripped.xsp
   cocoon/trunk/src/blocks/xsp/samples/javascript/stripped.xsp   (props changed)
      - copied unchanged from rev 55766, cocoon/branches/BRANCH_2_1_X/src/blocks/xsp/samples/javascript/stripped.xsp
   cocoon/trunk/src/blocks/xsp/samples/python/stripped.xsp   (props changed)
      - copied unchanged from rev 55766, cocoon/branches/BRANCH_2_1_X/src/blocks/xsp/samples/python/stripped.xsp
Modified:
   cocoon/trunk/src/blocks/python/java/org/apache/cocoon/components/language/markup/xsp/python/xsp.xsl
   cocoon/trunk/src/blocks/xsp/java/org/apache/cocoon/components/language/markup/xsp/java/xsp.xsl
   cocoon/trunk/src/blocks/xsp/java/org/apache/cocoon/components/language/markup/xsp/javascript/xsp.xsl
   cocoon/trunk/src/blocks/xsp/samples/java/simple.xsp
   cocoon/trunk/src/blocks/xsp/samples/samples.xml
   cocoon/trunk/status.xml
Log:
Bug 27176: Add space="strip" attribute to <xsp:page/>


Modified: cocoon/trunk/src/blocks/python/java/org/apache/cocoon/components/language/markup/xsp/python/xsp.xsl
==============================================================================
--- cocoon/trunk/src/blocks/python/java/org/apache/cocoon/components/language/markup/xsp/python/xsp.xsl
(original)
+++ cocoon/trunk/src/blocks/python/java/org/apache/cocoon/components/language/markup/xsp/python/xsp.xsl
Wed Oct 27 19:38:37 2004
@@ -16,11 +16,11 @@
 -->
 
 <!--
- * XSP Core logicsheet for the Python language
- *
- * @author <a href="mailto:vgritsenko@apache.org>Vadim Gritsenko</a>
- * @version CVS $Revision: 1.3 $ $Date: 2004/03/17 11:28:20 $
--->
+  - XSP Core logicsheet for the Python language
+  -
+  - @author <a href="mailto:vgritsenko@apache.org>Vadim Gritsenko</a>
+  - @version CVS $Id$
+  -->
 
 <xsl:stylesheet version="1.0"
                 xmlns:xsp="http://apache.org/xsp"
@@ -28,6 +28,12 @@
                 xmlns:XSLTExtension="org.apache.cocoon.components.language.markup.xsp.XSLTExtension">
   <xsl:output method="text"/>
 
+  <!--
+    Set to "strip" to strip empty space like XSLT.
+    Else space is preserved to remain compatible.
+  -->
+  <xsl:variable name="space" select="/xsp:page/@space"/>
+
   <xsl:variable name="xsp-uri" select="'http://apache.org/xsp'"/>
 
   <!--
@@ -64,6 +70,13 @@
   <xsl:template match="xsp:page">
 """ Generated by XSP. Edit at your own risk, :-)
 
+    <xsl:if test="$space = 'strip'">
+     Whitespace introduced in the XSP will not propagate into
+     the resulting XML document! To retain all whitespace,
+     remove the "space" attribute from the root &lt;xsp:page&gt;
+     element.
+    </xsl:if>
+
 Built-in beans for internal use:
     page           - "this" in Java
     contentHandler - page.contentHandler
@@ -644,7 +657,7 @@
   </xsl:template>
 
 
-  
+
   <xsl:template match="xsp:text">
     <xsl:param name="indent"/>
 
@@ -666,6 +679,16 @@
     <xsl:choose>
       <xsl:when test="namespace-uri(..) = $xsp-uri and (local-name(..) = 'logic' or local-name(..)
= 'expr')">
         <xsl:value-of select="."/>
+      </xsl:when>
+      <xsl:when test="$space = 'strip'">
+        <xsl:variable name="txt" select="normalize-space(.)"/>
+        <xsl:if test="$txt != '' and $txt != ' '">
+          <xsl:value-of select="$zindent"/>
+          <xsl:text>page.xspCharacters("</xsl:text>
+          <xsl:value-of select="XSLTExtension:escapeJava($extension, $txt)"/>
+          <xsl:text>")
+</xsl:text>
+        </xsl:if>
       </xsl:when>
       <xsl:otherwise>
         <xsl:value-of select="$zindent"/>

Modified: cocoon/trunk/src/blocks/xsp/java/org/apache/cocoon/components/language/markup/xsp/java/xsp.xsl
==============================================================================
--- cocoon/trunk/src/blocks/xsp/java/org/apache/cocoon/components/language/markup/xsp/java/xsp.xsl
(original)
+++ cocoon/trunk/src/blocks/xsp/java/org/apache/cocoon/components/language/markup/xsp/java/xsp.xsl
Wed Oct 27 19:38:37 2004
@@ -14,13 +14,14 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 -->
-<!-- CVS $Id$-->
+
 <!--
- * XSP Core logicsheet for the Java language
- *
- * @author <a href="mailto:ricardo@apache.org>Ricardo Rocha</a>
- * @author <a href="sylvain.wallez@anyware-tech.com">Sylvain Wallez</a>
--->
+  - XSP Core logicsheet for the Java language
+  -
+  - @author <a href="mailto:ricardo@apache.org>Ricardo Rocha</a>
+  - @author <a href="sylvain.wallez@anyware-tech.com">Sylvain Wallez</a>
+  - @version CVS $Id$
+  -->
 
 <xsl:stylesheet version="1.0"
                 xmlns:xsp="http://apache.org/xsp"
@@ -28,6 +29,12 @@
                 xmlns:XSLTExtension="org.apache.cocoon.components.language.markup.xsp.XSLTExtension">
   <xsl:output method="text"/>
 
+  <!--
+    Set to "strip" to strip empty space like XSLT.
+    Else space is preserved to remain compatible.
+  -->
+  <xsl:variable name="space" select="/xsp:page/@space"/>
+
   <xsl:variable name="xsp-uri" select="'http://apache.org/xsp'"/>
 
   <!--
@@ -49,12 +56,24 @@
   </xsl:template>
 
   <xsl:template match="xsp:page">
+    /*
+     * Generated by XSP. Edit at your own risk, :-)
+     */
+
+    <xsl:if test="$space = 'strip'">
+    /*
+     * Whitespace introduced in the XSP will not propagate into
+     * the resulting XML document!
+     * To retain all whitespace, remove the "space" attribute from
+     * the root &lt;xsp:page&gt; element.
+     */
+    </xsl:if>
+
     package <xsl:value-of select="translate(@file-path, '/', '.')"/>;
 
     import java.io.File;
     import java.io.IOException;
     import java.io.StringReader;
-    //import java.net.*;
     import java.util.Date;
     import java.util.List;
     import java.util.Stack;
@@ -67,12 +86,10 @@
     import org.apache.avalon.framework.service.ServiceManager;
     import org.apache.avalon.framework.service.ServiceSelector;
     import org.apache.avalon.framework.context.Context;
-    //import org.apache.avalon.framework.util.*;
 
     import org.apache.cocoon.Constants;
     import org.apache.cocoon.ProcessingException;
     import org.apache.cocoon.generation.Generator;
-    //import org.apache.cocoon.util.*;
 
     import org.apache.cocoon.components.language.markup.xsp.XSPGenerator;
     import org.apache.cocoon.components.language.markup.xsp.XSPObjectHelper;
@@ -82,20 +99,16 @@
 
     /* User Imports */
     <xsl:for-each select="xsp:structure/xsp:include">
-      import <xsl:value-of select="."/>;
+    import <xsl:value-of select="."/>;
     </xsl:for-each>
 
-    /**
-     * Generated by XSP. Edit at your own risk, :-)
-     */
     public class <xsl:value-of select="@file-name"/> extends XSPGenerator {
-
         // Files this XSP depends on
         private static File[] _dependentFiles = new File[] {
           <xsl:for-each select="//xsp:dependency">
-                  new File("<xsl:value-of select="translate(., '\','/')"/>"),
-                </xsl:for-each>
-            };
+            new File("<xsl:value-of select="translate(., '\','/')"/>"),
+          </xsl:for-each>
+        };
 
         // Initialize attributes used by modifiedSince() (see AbstractServerPage)
         {
@@ -485,6 +498,12 @@
     <xsl:choose>
       <xsl:when test="namespace-uri(..) = $xsp-uri and (local-name(..) = 'logic' or local-name(..)
= 'expr')">
         <xsl:value-of select="XSLTExtension:escape($extension, .)"/>
+      </xsl:when>
+      <xsl:when test="$space = 'strip'">
+        <xsl:variable name="txt" select="normalize-space(.)"/>
+        <xsl:if test="$txt != '' and $txt != ' '">
+        this.characters("<xsl:value-of select="XSLTExtension:escapeJava($extension, $txt)"/>");
+        </xsl:if>
       </xsl:when>
       <xsl:otherwise>
         this.characters("<xsl:value-of select="XSLTExtension:escapeJava($extension, .)"/>");

Modified: cocoon/trunk/src/blocks/xsp/java/org/apache/cocoon/components/language/markup/xsp/javascript/xsp.xsl
==============================================================================
--- cocoon/trunk/src/blocks/xsp/java/org/apache/cocoon/components/language/markup/xsp/javascript/xsp.xsl
(original)
+++ cocoon/trunk/src/blocks/xsp/java/org/apache/cocoon/components/language/markup/xsp/javascript/xsp.xsl
Wed Oct 27 19:38:37 2004
@@ -14,12 +14,13 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 -->
-<!-- CVS $Id: xsp.xsl,v 1.3 2004/04/02 21:32:34 joerg Exp $-->
+
 <!--
- * XSP Core logicsheet for the JavaScript language
- *
- * @author <a href="mailto:vgritsenko@apache.org>Vadim Gritsenko</a>
--->
+  - XSP Core logicsheet for the JavaScript language
+  -
+  - @author <a href="mailto:vgritsenko@apache.org>Vadim Gritsenko</a>
+  - @version CVS $Id$
+  -->
 
 <xsl:stylesheet version="1.0"
                 xmlns:xsp="http://apache.org/xsp"
@@ -27,6 +28,12 @@
                 xmlns:XSLTExtension="org.apache.cocoon.components.language.markup.xsp.XSLTExtension">
   <xsl:output method="text"/>
 
+  <!--
+    Set to "strip" to strip empty space like XSLT.
+    Else space is preserved to remain compatible.
+  -->
+  <xsl:variable name="space" select="/xsp:page/@space"/>
+
   <xsl:variable name="xsp-uri" select="'http://apache.org/xsp'"/>
 
   <!--
@@ -59,6 +66,15 @@
   <xsl:template match="xsp:page" xml:space="preserve">
     // Generated by XSP. Edit at your own risk, :-)
 
+    <xsl:if test="$space = 'strip'">
+    /*
+     * Whitespace introduced in the XSP will not propagate into
+     * the resulting XML document!
+     * To retain all whitespace, remove the "space" attribute from
+     * the root &lt;xsp:page&gt; element.
+     */
+    </xsl:if>
+
     /* Built-in beans not available for use */
     // page           - "this" in Java
     // logger         - Logger
@@ -411,6 +427,12 @@
     <xsl:choose>
       <xsl:when test="namespace-uri(..) = $xsp-uri and (local-name(..) = 'logic' or local-name(..)
= 'expr')">
         <xsl:value-of select="."/>
+      </xsl:when>
+      <xsl:when test="$space = 'strip'">
+        <xsl:variable name="txt" select="normalize-space(.)"/>
+        <xsl:if test="$txt != '' and $txt != ' '">
+        page.xspCharacters("<xsl:value-of select="XSLTExtension:escapeJava($extension,
$txt)"/>");
+        </xsl:if>
       </xsl:when>
       <xsl:otherwise>
         page.xspCharacters("<xsl:value-of select="XSLTExtension:escapeJava($extension,
.)"/>");

Modified: cocoon/trunk/src/blocks/xsp/samples/java/simple.xsp
==============================================================================
--- cocoon/trunk/src/blocks/xsp/samples/java/simple.xsp	(original)
+++ cocoon/trunk/src/blocks/xsp/samples/java/simple.xsp	Wed Oct 27 19:38:37 2004
@@ -15,7 +15,7 @@
   limitations under the License.
 -->
 
-<!-- CVS $Id: simple.xsp,v 1.2 2004/04/05 12:25:30 antonio Exp $ -->
+<!-- CVS $Id$ -->
 
 <xsp:page language="java"
           xmlns:xsp="http://apache.org/xsp"
@@ -25,8 +25,8 @@
           xmlns:input="http://apache.org/cocoon/xsp/input/1.0">
 
   <page>
-  <log:logger name="xsp-sample" filename="xsp-sample.log"/>
-  <log:debug>Processing the beginning of the page</log:debug>
+   <log:logger name="xsp-sample" filename="xsp-sample.log"/>
+   <log:debug>Processing the beginning of the page</log:debug>
 
    <title>A Simple XSP Page</title>
 
@@ -98,11 +98,10 @@
    </para>
    
    <para>
-   	 Access to input modules configured in cocoon.xconf: 
-   	 <input:get-attribute module="cocoon-properties" name="fullname"/>
-   	 <input:get-attribute module="cocoon-properties" name="version"/>
+     Access to input modules configured in cocoon.xconf: 
+     <input:get-attribute module="cocoon-properties" name="fullname"/>
+     <input:get-attribute module="cocoon-properties" name="version"/>
    </para>
-   	 
 
    <xsp-request:get-header-names/>
 

Modified: cocoon/trunk/src/blocks/xsp/samples/samples.xml
==============================================================================
--- cocoon/trunk/src/blocks/xsp/samples/samples.xml	(original)
+++ cocoon/trunk/src/blocks/xsp/samples/samples.xml	Wed Oct 27 19:38:37 2004
@@ -15,7 +15,7 @@
   limitations under the License.
 -->
 
-<!-- CVS $Id: samples.xml,v 1.4 2004/04/05 12:25:35 antonio Exp $ -->
+<!-- CVS $Id$ -->
 
 <samples xmlns:xlink="http://www.w3.org/1999/xlink" name="XSP Block Samples">
 
@@ -37,6 +37,9 @@
   </group>
 
   <group name="eXtensible Server Pages in Java">
+   <sample name="Hello Stripped" href="java/stripped">
+    Hello page with stripped empty spaces
+   </sample>
    <sample name="Simple XSP" href="java/simple">
     Simple XSP example showing usage of several logicsheets.
    </sample>
@@ -67,6 +70,9 @@
    <sample name="Hello" href="js/hello">
     Hello in Javascript
    </sample>
+   <sample name="Hello Stripped" href="js/stripped">
+    Hello with stripped empty spaces
+   </sample>
    <sample name="Simple" href="js/simple" xlink:role="dynamic">
     Another simple XSP example.
    </sample>
@@ -88,6 +94,9 @@
    </note>
    <sample name="Hello" href="python/hello">
     Hello in Python
+   </sample>
+   <sample name="Hello Stripped" href="python/stripped">
+    Hello with stripped empty spaces
    </sample>
   </group>
 

Modified: cocoon/trunk/status.xml
==============================================================================
--- cocoon/trunk/status.xml	(original)
+++ cocoon/trunk/status.xml	Wed Oct 27 19:38:37 2004
@@ -322,6 +322,10 @@
    </action>
  </release>
  <release version="2.1.6" date="TBD">
+   <action dev="VG" type="fix" fixes-bug="27176" due-to="Guillaume Deflache" due-to-email="guillaume@anyware-tech.com">
+     XSP Block: Add space="strip" attribute support for &lt;xsp:page&gt;
+     element. When present, all extra whitespace from XSP source is stripped.
+   </action>
    <action dev="VG" type="fix" fixes-bug="30849">
      XMLDB Block: Fix NullPointerException in XMLDBTransformer if specified
      collection does not exist.

Mime
View raw message