cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vgritse...@apache.org
Subject svn commit: rev 55766 - in cocoon/branches/BRANCH_2_1_X: . 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:33:50 GMT
Author: vgritsenko
Date: Wed Oct 27 19:33:49 2004
New Revision: 55766

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


Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/python/java/org/apache/cocoon/components/language/markup/xsp/python/xsp.xsl
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/python/java/org/apache/cocoon/components/language/markup/xsp/python/xsp.xsl
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/python/java/org/apache/cocoon/components/language/markup/xsp/python/xsp.xsl
Wed Oct 27 19:33:49 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/branches/BRANCH_2_1_X/src/blocks/xsp/java/org/apache/cocoon/components/language/markup/xsp/java/xsp.xsl
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/xsp/java/org/apache/cocoon/components/language/markup/xsp/java/xsp.xsl
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/xsp/java/org/apache/cocoon/components/language/markup/xsp/java/xsp.xsl
Wed Oct 27 19:33:49 2004
@@ -14,13 +14,14 @@
   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:33 joerg Exp $-->
+
 <!--
- * 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,33 +56,41 @@
   </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;
 
-    //import org.w3c.dom.*;
     import org.xml.sax.InputSource;
     import org.xml.sax.SAXException;
     import org.xml.sax.helpers.AttributesImpl;
 
-    //import org.apache.avalon.framework.*;
     import org.apache.avalon.framework.component.Component;
     import org.apache.avalon.framework.component.ComponentException;
     import org.apache.avalon.framework.component.ComponentManager;
     import org.apache.avalon.framework.component.ComponentSelector;
     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;
@@ -85,20 +100,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)
         {
@@ -488,6 +499,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/branches/BRANCH_2_1_X/src/blocks/xsp/java/org/apache/cocoon/components/language/markup/xsp/javascript/xsp.xsl
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/xsp/java/org/apache/cocoon/components/language/markup/xsp/javascript/xsp.xsl
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/xsp/java/org/apache/cocoon/components/language/markup/xsp/javascript/xsp.xsl
Wed Oct 27 19:33:49 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/branches/BRANCH_2_1_X/src/blocks/xsp/samples/java/simple.xsp
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/xsp/samples/java/simple.xsp	(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/xsp/samples/java/simple.xsp	Wed Oct 27 19:33:49
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/>
 

Copied: cocoon/branches/BRANCH_2_1_X/src/blocks/xsp/samples/java/stripped.xsp (from rev 55733,
cocoon/branches/BRANCH_2_1_X/src/blocks/xsp/samples/java/hello.xsp)
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/xsp/samples/java/hello.xsp	(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/xsp/samples/java/stripped.xsp	Wed Oct 27 19:33:49
2004
@@ -15,10 +15,11 @@
   limitations under the License.
 -->
 
-<!-- CVS $Id: hello.xsp,v 1.2 2004/04/05 12:25:30 antonio Exp $ -->
+<!-- CVS $Id$ -->
 
 <xsp:page language="java"
-          xmlns:xsp="http://apache.org/xsp">
+          xmlns:xsp="http://apache.org/xsp"
+          space="strip">
 
   <page>
     <title>Hello</title>

Copied: cocoon/branches/BRANCH_2_1_X/src/blocks/xsp/samples/javascript/stripped.xsp (from
rev 55733, cocoon/branches/BRANCH_2_1_X/src/blocks/xsp/samples/javascript/hello.xsp)
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/xsp/samples/javascript/hello.xsp	(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/xsp/samples/javascript/stripped.xsp	Wed Oct 27
19:33:49 2004
@@ -15,9 +15,11 @@
   limitations under the License.
 -->
 
-<!-- CVS $Id: hello.xsp,v 1.2 2004/04/05 12:25:32 antonio Exp $ -->
+<!-- CVS $Id$ -->
 
-<xsp:page language="javascript" xmlns:xsp="http://apache.org/xsp">
+<xsp:page language="javascript"
+          xmlns:xsp="http://apache.org/xsp"
+          space="strip">
   <page>
     <title>Hello</title>
     <content>

Copied: cocoon/branches/BRANCH_2_1_X/src/blocks/xsp/samples/python/stripped.xsp (from rev
55733, cocoon/branches/BRANCH_2_1_X/src/blocks/xsp/samples/python/hello.xsp)
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/xsp/samples/python/hello.xsp	(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/xsp/samples/python/stripped.xsp	Wed Oct 27 19:33:49
2004
@@ -15,7 +15,9 @@
   limitations under the License.
 -->
 
-<xsp:page language="python" xmlns:xsp="http://apache.org/xsp">
+<xsp:page language="python"
+          xmlns:xsp="http://apache.org/xsp"
+          space="strip">
   <page>
     <title>Hello from XSP page in Python</title>
     <para>

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/xsp/samples/samples.xml
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/xsp/samples/samples.xml	(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/xsp/samples/samples.xml	Wed Oct 27 19:33:49 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/branches/BRANCH_2_1_X/status.xml
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/status.xml	(original)
+++ cocoon/branches/BRANCH_2_1_X/status.xml	Wed Oct 27 19:33:49 2004
@@ -136,7 +136,7 @@
 
     <action context="code" assigned-to="SW">
       For 2.2: Views must start not from the first encountered label, but from the last one
-      (see http://marc.theaimsgroup.com/?l=xml-cocoon-dev&amp;m=101784499622172&amp;w=2)
+      (see http://marc.theaimsgroup.com/?l=xml-cocoon-dev&amp;m=101784499622172)
     </action>
 
     <action context="code" assigned-to="NKB">
@@ -181,12 +181,6 @@
     </action>
 
     <action context="code">
-      Remove all useless blank strings in XSP-generated code that hinder performances.
-      This should be configurable (through an attribute?) to be able to keep them when
-      needed.
-    </action>
-
-    <action context="code">
       Lucene is writing info to stdout when searching.
     </action>
 
@@ -205,6 +199,10 @@
 
   <changes>
  <release version="@version@" date="@date@">
+   <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