Hi,
I am trying to zip a
directory and all the content of the directory
I have a directory
structure as follows:
C:\Directory
|
|--
dirA
|--------FileA.text
|--------FileB.text
|--
dirB
|--FileRootA.txt
|--FileRootB.txt
I have written an
xsl to read this using Directory generator and zip the files and the directories
recursively till n level..
What I found, all
the files at all the levels are getting zipped but not
directory.
For directories I
get the following error:
'If I comment the
zip entry for directories, files gets zipped correctly.
"org.apache.cocoon.ProcessingException: Failed to
execute pipeline.: java.lang.RuntimeException:
org.apache.excalibur.source.SourceNotFoundException: file:/C:/directory/ doesn't
exist"
Though the
directory very much exists. I have tried hard coding and adding the same
also, but no luck.
I have the xsl
written as below:
Can some one please
check out and let me know where I am going wrong, or is it that we can only zip
files using Cocoon and not directories.
Thanks in
advance.
Regards,
Moin
========================
Sitemap.xmap is as
follows
<map:match
pattern="zipFolderActions">
<map:generate type="directory" src="">
<map:parameter name="depth" value="1000"/>
<map:parameter name="use-request-parameters" value="true"/>
</map:generate>
<map:transform src=""/>
<map:serialize type="zip"/>
</map:match>
<map:generate type="directory" src="">
<map:parameter name="depth" value="1000"/>
<map:parameter name="use-request-parameters" value="true"/>
</map:generate>
<map:transform src=""/>
<map:serialize type="zip"/>
</map:match>
================================================
dirzip.xsl is as
follows:
<?xml
version="1.0"?>
<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: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:param
name="dirprefix"/>
<xsl:template
match="/">
<zip:archive>
<xsl:for-each select="//dir:directory">
<xsl:for-each select="//dir:directory">
<xsl:variable name="directoryPath">
<xsl:for-each select="ancestor::*">
<xsl:value-of select="@name"/>
<xsl:text>/</xsl:text>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="dirName">
<xsl:value-of select="@name"/>
</xsl:variable>
<xsl:variable name="DirToBeZipped"><xsl:value-of select="concat($directoryPath,$dirName,'/')"/></xsl:variable>
<zip:entry name="{dirName}" src=""/>
<!-- add code to get the files in each directory -->
<xsl:for-each select="./dir:file">
<xsl:variable name="filePath">
<xsl:for-each select="ancestor::*">
<xsl:value-of select="@name"/>
<xsl:text>/</xsl:text>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="fileName">
<xsl:value-of select="@name"/>
</xsl:variable>
<xsl:variable name="fileToBeZipped"><xsl:value-of select="concat($filePath,$fileName)"/></xsl:variable>
<zip:entry name="{$fileName}" src=""/>
</xsl:for-each>
<!-- end of code to get files in each directory -->
</xsl:for-each>
<!-- end of code to get files in each directory -->
</xsl:for-each>
</zip:archive>
</xsl:template>
</xsl:stylesheet>
</xsl:stylesheet>
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 [EMAIL PROTECTED] immediately and destroy all copies of this message and any attachments. |