cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anathan...@apache.org
Subject svn commit: r234126 - in /cocoon: blocks/xsp/trunk/java/org/apache/cocoon/components/language/markup/xsp/java/xsp.xsl blocks/xsp/trunk/samples/java/simple.xsp trunk/status.xml
Date Sat, 20 Aug 2005 20:10:47 GMT
Author: anathaniel
Date: Sat Aug 20 13:10:41 2005
New Revision: 234126

URL: http://svn.apache.org/viewcvs?rev=234126&view=rev
Log:
XSP block: Move AttributeImpl in xsp.xsl to class scope.
That allows top-level xsp:logic to define markup generating methods.
Variable xspAttr renamed to _xspAttr to be avoid breaking existing
XSPs which already use that trick.

Modified:
    cocoon/blocks/xsp/trunk/java/org/apache/cocoon/components/language/markup/xsp/java/xsp.xsl
    cocoon/blocks/xsp/trunk/samples/java/simple.xsp
    cocoon/trunk/status.xml

Modified: cocoon/blocks/xsp/trunk/java/org/apache/cocoon/components/language/markup/xsp/java/xsp.xsl
URL: http://svn.apache.org/viewcvs/cocoon/blocks/xsp/trunk/java/org/apache/cocoon/components/language/markup/xsp/java/xsp.xsl?rev=234126&r1=234125&r2=234126&view=diff
==============================================================================
--- cocoon/blocks/xsp/trunk/java/org/apache/cocoon/components/language/markup/xsp/java/xsp.xsl
(original)
+++ cocoon/blocks/xsp/trunk/java/org/apache/cocoon/components/language/markup/xsp/java/xsp.xsl
Sat Aug 20 13:10:41 2005
@@ -116,6 +116,10 @@
             this.dependencies = _dependentFiles;
         }
 
+        // Internally used list of attributes for SAX events.  Being on
+        // class scope allows xsp:logic to define markup generating methods.
+        private AttributesImpl _xspAttr = new AttributesImpl();
+
         /* Built-in parameters available for use */
         // context    - org.apache.cocoon.environment.Context
         // request    - org.apache.cocoon.environment.Request
@@ -137,7 +141,7 @@
             </xsl:for-each>
 
             this.contentHandler.startDocument();
-            AttributesImpl xspAttr = new AttributesImpl();
+            _xspAttr.clear();
 
             <!-- Generate top-level processing instructions -->
             <xsl:apply-templates select="/processing-instruction()"/>
@@ -266,10 +270,10 @@
       <xsl:copy-of select="$uri"/>,
       <xsl:copy-of select="$name"/>,
       <xsl:copy-of select="$raw-name"/>,
-      xspAttr
+      _xspAttr
     );
 
-    xspAttr.clear();
+    _xspAttr.clear();
 
     <xsl:apply-templates select="node()[not(
       (namespace-uri(.) = $xsp-uri and local-name(.) = 'attribute') or
@@ -364,7 +368,7 @@
       <xsl:if test="not(text()|xsp:expr|xsp:text)"> "" </xsl:if>
     </xsl:variable>
 
-    xspAttr.addAttribute(
+    _xspAttr.addAttribute(
       <xsl:copy-of select="$uri"/>,
       <xsl:copy-of select="$name"/>,
       <xsl:copy-of select="$raw-name"/>,
@@ -455,9 +459,9 @@
       "<xsl:value-of select="namespace-uri(.)"/>",
       "<xsl:value-of select="local-name(.)"/>",
       "<xsl:value-of select="name(.)"/>",
-      xspAttr
+      _xspAttr
     );
-    xspAttr.clear();
+    _xspAttr.clear();
 
     <xsl:apply-templates select="node()[not(
         (namespace-uri(.) = $xsp-uri and local-name(.) = 'attribute') or
@@ -484,7 +488,7 @@
   <xsl:template match="@*">
     <!-- Filter out namespace declaration attributes -->
     <xsl:if test="not(starts-with(name(.), 'xmlns:'))">
-    xspAttr.addAttribute(
+    _xspAttr.addAttribute(
       "<xsl:value-of select="namespace-uri(.)"/>",
       "<xsl:value-of select="local-name(.)"/>",
       "<xsl:value-of select="name(.)"/>",

Modified: cocoon/blocks/xsp/trunk/samples/java/simple.xsp
URL: http://svn.apache.org/viewcvs/cocoon/blocks/xsp/trunk/samples/java/simple.xsp?rev=234126&r1=234125&r2=234126&view=diff
==============================================================================
--- cocoon/blocks/xsp/trunk/samples/java/simple.xsp (original)
+++ cocoon/blocks/xsp/trunk/samples/java/simple.xsp Sat Aug 20 13:10:41 2005
@@ -26,6 +26,18 @@
           xmlns:capture="http://apache.org/cocoon/capture/1.0"
           xmlns:input="http://apache.org/cocoon/xsp/input/1.0">
 
+  <xsp:logic>
+    void sayHello(int n) throws SAXException {
+    <ul>
+      <xsp:logic>
+        for (int i = 0; i &lt; n; i++) {
+        <li>Hello world <xsp:expr>i+1</xsp:expr></li>
+        }
+      </xsp:logic>
+    </ul>
+    }
+  </xsp:logic>
+
   <page>
     <!-- Use own logger sub-category for this logicsheet -->
     <log:logger name="simple"/>
@@ -56,6 +68,11 @@
           }
         </xsp:logic>
       </ul>
+
+      <para>The following list was generated by a subroutine:</para>
+      <xsp:logic>
+        sayHello(3);
+      </xsp:logic>
 
       <xsp:element>
         <xsp:param name="name"><xsp:expr>"P".toLowerCase()</xsp:expr></xsp:param>

Modified: cocoon/trunk/status.xml
URL: http://svn.apache.org/viewcvs/cocoon/trunk/status.xml?rev=234126&r1=234125&r2=234126&view=diff
==============================================================================
--- cocoon/trunk/status.xml (original)
+++ cocoon/trunk/status.xml Sat Aug 20 13:10:41 2005
@@ -198,6 +198,12 @@
   <changes>
   <release version="@version@" date="@date@">
     <action dev="AN" type="fix">
+      XSP block: Move AttributeImpl in xsp.xsl to class scope.
+      That allows top-level xsp:logic to define markup generating methods.
+      Variable xspAttr renamed to _xspAttr to be avoid breaking existing
+      XSPs which already use that trick.
+    </action>
+    <action dev="AN" type="fix">
       XSP block: Add xsp:expr and various other contexts where text must be
       passed through XSLTExtension:escape in order to preserve non-ASCII
       characters in Java string constants independently of the XSP source file



Mime
View raw message