cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anathan...@apache.org
Subject svn commit: r436829 - in /cocoon/trunk/blocks/cocoon-xsp: cocoon-xsp-impl/ cocoon-xsp-sample/src/main/resources/COB-INF/ cocoon-xsp-sample/src/main/resources/COB-INF/java/
Date Fri, 25 Aug 2006 15:23:00 GMT
Author: anathaniel
Date: Fri Aug 25 08:22:59 2006
New Revision: 436829

URL: http://svn.apache.org/viewvc?rev=436829&view=rev
Log:
XSP block: Add example for on-the-fly generation of ZIP file.

Added:
    cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-sample/src/main/resources/COB-INF/java/zipping.xsp
  (with props)
Modified:
    cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/status.xml
    cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-sample/src/main/resources/COB-INF/samples.xml
    cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-sample/src/main/resources/COB-INF/sitemap.xmap

Modified: cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/status.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/status.xml?rev=436829&r1=436828&r2=436829&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/status.xml (original)
+++ cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-impl/status.xml Fri Aug 25 08:22:59 2006
@@ -65,6 +65,9 @@
  <!-- The following list contains the changes since the latest 2.1.x version. -->
  <changes>
   <release version="@version@" date="@date@">
+    <action dev="AN" type="add">
+      XSP block: Add example for on-the-fly generation of ZIP file.
+    </action>
     <action dev="AN" type="fix">
       XSP block: Suppress xmlns:xsp namespace declaration on XSP generated root element.
     </action>

Added: cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-sample/src/main/resources/COB-INF/java/zipping.xsp
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-sample/src/main/resources/COB-INF/java/zipping.xsp?rev=436829&view=auto
==============================================================================
--- cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-sample/src/main/resources/COB-INF/java/zipping.xsp
(added)
+++ cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-sample/src/main/resources/COB-INF/java/zipping.xsp
Fri Aug 25 08:22:59 2006
@@ -0,0 +1,78 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You 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.
+-->
+
+<!-- CVS $Id$ -->
+
+<!--
+  This XSP produces markup for the ZipArchiveSerializer to zip all java/*.xsp files.
+  
+  Note that this simple example could as well be implemented using the
+  DirectoryGenerator and transformed by a stylesheet to zip: markup.
+-->
+ 
+<xsp:page language="java"
+          xmlns:zip="http://apache.org/cocoon/zip-archive/1.0"
+          xmlns:xsp="http://apache.org/xsp">
+
+  <xsp:structure>
+    <xsp:include>org.apache.excalibur.source.impl.FileSource</xsp:include>
+    <xsp:include>java.io.File</xsp:include>
+  </xsp:structure>
+  
+  <zip:archive>
+    <xsp:logic>
+    
+      // Get the samples/java directory.
+      // File URIs are resolved relative to the location of the sitemap.xmap.
+      
+      FileSource source = null;
+      File dir = null;
+      try {
+        source = (FileSource) resolver.resolveURI("java");
+        dir = source.getFile();
+      }
+      finally {
+        resolver.release(source);
+      }
+        
+      // Scan directory for *.xsp files.
+      
+      File[] files = dir.listFiles();
+
+      boolean found = false;
+      for ( int i = 0, n = files.length; i &lt; n; i++ ) {
+        File file = files[i];
+        String filename = file.getName();
+        if ( !filename.endsWith(".xsp") ) continue;
+        found = true;
+      
+        <zip:entry>
+          <xsp:attribute name="name"><xsp:expr>filename</xsp:expr></xsp:attribute>
+          <xsp:attribute name="src"><xsp:expr>file.getPath()</xsp:expr></xsp:attribute>
+        </zip:entry>
+      } // for files
+
+      // ZIP files cannot be completely empty.      
+      if ( !found ) {
+        <zip:entry name="README.txt" serializer="text">
+          No match for *.xsp in <xsp:expr>dir.getPath()</xsp:expr>.
+        </zip:entry>
+      } // if !found
+    </xsp:logic>
+  </zip:archive>
+</xsp:page>

Propchange: cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-sample/src/main/resources/COB-INF/java/zipping.xsp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-sample/src/main/resources/COB-INF/java/zipping.xsp
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-sample/src/main/resources/COB-INF/samples.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-sample/src/main/resources/COB-INF/samples.xml?rev=436829&r1=436828&r2=436829&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-sample/src/main/resources/COB-INF/samples.xml
(original)
+++ cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-sample/src/main/resources/COB-INF/samples.xml
Fri Aug 25 08:22:59 2006
@@ -73,6 +73,9 @@
    <sample name="Escaping" href="java/escaping" xlink:role="dynamic">
     Escaping of non-ASCII characters.
    </sample>
+   <sample name="Zipping" href="java/zipping.zip" xlink:role="dynamic">
+    On-the-fly zipping of filtered files.
+   </sample>
   </group>
 
   <group name="eXtensible Server Pages in Javascript">

Modified: cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-sample/src/main/resources/COB-INF/sitemap.xmap
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-sample/src/main/resources/COB-INF/sitemap.xmap?rev=436829&r1=436828&r2=436829&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-sample/src/main/resources/COB-INF/sitemap.xmap
(original)
+++ cocoon/trunk/blocks/cocoon-xsp/cocoon-xsp-sample/src/main/resources/COB-INF/sitemap.xmap
Fri Aug 25 08:22:59 2006
@@ -56,6 +56,11 @@
         <map:serialize/>
       </map:match>
 
+      <map:match pattern="java/*.zip">
+        <map:generate src="java/{1}.xsp" type="serverpages" label="content"/>
+        <map:serialize type="zip"/>
+      </map:match>
+
       <map:match pattern="java/*">
         <map:generate src="java/{1}.xsp" type="serverpages"/>
         <map:transform src="context://samples/blocks/dynamic-page2html.xsl">



Mime
View raw message