You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by mo...@wipro.com on 2004/05/10 15:37:39 UTC

Merging DirectoryGenerator and ZipArchiveSerializer

Hi,


I am trying to zip up contents of a directory.
I have successfully got the Zip and directory working stand alone.
Now I am trying to pass a directory and then zip the contents.
I have pasted the contents of sitemap.xmap and .xsl file and the .xml
file generated after reading the directory for your reference.

I am getting error
"Failed to execute pipeline.

org.apache.cocoon.ProcessingException: Failed to execute pipeline.:
java.lang.RuntimeException: java.util.zip.ZipException: ZIP file must
have at least one entry
"
If I use "html" to serialize instead of "zip", the contents of the
directory are getting rendered correctly.

Can some one let me know where I am going wrong.
Thanks in advance.
Regards,
M

Sitemap.xmap
========================================================================
=
<map:match pattern="zipFolderActions">

 	<map:generate type="directory"
src="./{request-param:zipFolders}">
          	 <map:parameter name="depth" value="4"/>
          	 <map:parameter name="use-request-parameters"
value="true"/>
           </map:generate>
   	<map:transform src="stylesheets/dirzip.xsl"/>
        <map:serialize type="xml"/>

    </map:match>

===============================================================

My DirZip.xsl is as follows:

========================================================================
=
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:dir="http://apache.org/cocoon/directory/2.0">
    
<zip-archive:archive
xmlns:zip-archive="http://apache.org/cocoon/zip-archive/1.0">

<xsl:param name="dirprefix"/>
<xsl:template match="/">

<xsl:for-each select="dir:directory/dir:file">

<zip-archive:entry>
  <xsl:attribute name="name" value="zipFile">
  </xsl:attribute>
  <xsl:attribute name="src"><xsl:value-of
select='dir:directory/dir:file@name'/>
  </xsl:attribute>
 

</zip-archive:entry>
</xsl:for-each>


</xsl:template>
</zip-archive:archive>
</xsl:stylesheet>


=========================================

The output of the directory reader is fine..It prints the following:

  <?xml version="1.0" encoding="ISO-8859-1" ?>
- <dir:directory xmlns:dir="http://apache.org/cocoon/directory/2.0"
name="CVS" lastModified="1083839789750" date="5/6/04 4:06 PM" size="0"
sort="name" reverse="false" requested="true">
  <dir:file name="Entries" lastModified="1083817692000" date="5/6/04
9:58 AM" size="688" />
  <dir:file name="Entries.Extra" lastModified="1083817692000"
date="5/6/04 9:58 AM" size="343" />
  <dir:file name="Repository" lastModified="1083740334000" date="5/5/04
12:28 PM" size="12" />
  <dir:file name="Root" lastModified="1083740334000" date="5/5/04 12:28
PM" size="48" />
  </dir:directory>

Confidentiality Notice

The information contained in this electronic message and any attachments to this message are intended
for the exclusive use of the addressee(s) and may contain confidential or privileged information. If
you are not the intended recipient, please notify the sender at Wipro or Mailadmin@wipro.com immediately
and destroy all copies of this message and any attachments.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Merging DirectoryGenerator and ZipArchiveSerializer

Posted by Joerg Heinicke <jo...@gmx.de>.
On 10.05.2004 15:37, moinuddin.ahmed@wipro.com wrote:

> Hi,
> 
> 
> I am trying to zip up contents of a directory.
> I have successfully got the Zip and directory working stand alone.
> Now I am trying to pass a directory and then zip the contents.
> I have pasted the contents of sitemap.xmap and .xsl file and the .xml
> file generated after reading the directory for your reference.

<xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:dir="http://apache.org/cocoon/directory/2.0"
      xmlns:zip="http://apache.org/cocoon/zip-archive/1.0">

<xsl:template match="/">
   <zip:archive>
     <xsl:apply-templates select="dir:directory"/>
   </zip:archive>
</xsl:template>

<xsl:template match="dir:directory">
   <xsl:apply-templates select="dir:directory/dir:file"/>
</xsl:template>

<xsl:template match="dir:file">
   <xsl:variable name="src">
     <xsl:for-each select="ancestor::*">
       <xsl:value-of select="@name"/>
       <xsl:text>/</xsl:text>
     </xsl:for-each>
     <xsl:value-of select="@name"/>
   </xsl:variable>
   <zip:entry name="{@name}" src="{$src}"/>
</xsl:template>

No tested. Fix the pathes in the way you need them.

Joerg

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Merging DirectoryGenerator and ZipArchiveSerializer

Posted by Askild Aaberg Olsen <as...@xangeli.com>.
I have not used the ZipArchiveSerializer, but your XSLT is somewhat wrong:

The <zip-archive:archive>-element should be inside the
<xsl:template>-element.

Askild
-

moinuddin.ahmed wrote:
> Hi,
> 
> 
> I am trying to zip up contents of a directory.
> I have successfully got the Zip and directory working stand 
> alone. Now I am trying to pass a directory and then zip the 
> contents. I have pasted the contents of sitemap.xmap and .xsl 
> file and the .xml file generated after reading the directory 
> for your reference.
> 
> I am getting error
> 
> "Failed to execute pipeline.
> 
> org.apache.cocoon.ProcessingException: Failed to execute pipeline.:
> java.lang.RuntimeException: java.util.zip.ZipException: ZIP 
> file must have at least one entry " If I use "html" to 
> serialize instead of "zip", the contents of the directory are 
> getting rendered correctly.
> 
> Can some one let me know where I am going wrong.
> Thanks in advance.
> Regards,
> M
> 
> Sitemap.xmap 
> ==============================================================
> ==========
> =
> <map:match pattern="zipFolderActions">
> 
> 
>  	<map:generate type="directory" 
> src="./{request-param:zipFolders}">
>           	 <map:parameter name="depth" value="4"/>
>           	 <map:parameter name="use-request-parameters" 
> value="true"/>
>            </map:generate>
>    	<map:transform src="stylesheets/dirzip.xsl"/>
>         <map:serialize type="xml"/>
> 
>     </map:match>
> 
> ===============================================================
> 
> My DirZip.xsl is as follows:
> 
> ==============================================================
> ==========
> =
> <?xml version="1.0" encoding="iso-8859-1"?>
> <xsl:stylesheet version="1.0"
> 
>      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>      xmlns:dir="http://apache.org/cocoon/directory/2.0">
>     
> 
> <zip-archive:archive 
> xmlns:zip-archive="http://apache.org/cocoon/zip-archive/1.0">
> 
> <xsl:param name="dirprefix"/>
> <xsl:template match="/">
> 
> <xsl:for-each select="dir:directory/dir:file">
> 
> 
> <zip-archive:entry>
>   <xsl:attribute name="name" value="zipFile">
>   </xsl:attribute>
>   <xsl:attribute name="src"><xsl:value-of 
> select='dir:directory/dir:file@name'/>
>   </xsl:attribute>
>  
> 
> 
> </zip-archive:entry>
> </xsl:for-each>
> 
> 
> 
> 
> </xsl:template>
> </zip-archive:archive>
> </xsl:stylesheet>
> 
> 
> =========================================
> 
> The output of the directory reader is fine..It prints the following:
> 
>   <?xml version="1.0" encoding="ISO-8859-1" ?>
> 
> - <dir:directory xmlns:dir="http://apache.org/cocoon/directory/2.0"
> name="CVS" lastModified="1083839789750" date="5/6/04 4:06 PM" 
> size="0" sort="name" reverse="false" requested="true">
>   <dir:file name="Entries" lastModified="1083817692000" 
> date="5/6/04 9:58 AM" size="688" />
> 
>   <dir:file name="Entries.Extra" lastModified="1083817692000" 
> date="5/6/04 9:58 AM" size="343" />
> 
>   <dir:file name="Repository" lastModified="1083740334000" 
> date="5/5/04 12:28 PM" size="12" />
> 
>   <dir:file name="Root" lastModified="1083740334000" 
> date="5/5/04 12:28 PM" size="48" />
> 
>   </dir:directory>
> 
> Confidentiality Notice
> 
> 
> The information contained in this electronic message and any 
> attachments to this message are intended for the exclusive 
> use of the addressee(s) and may contain confidential or 
> privileged information. If you are not the intended 
> recipient, please notify the sender at Wipro or 
> Mailadmin@wipro.com immediately and destroy all copies of 
> this message and any attachments.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org