You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Steve Cameron <st...@utas.edu.au> on 2008/08/21 05:54:35 UTC

ZipArchiveSerializer question

Hello,

Is it possible to use the ZipArchiveSerializer and process the generator
output straight off without sending it to a disk file first?

I think this stream compression is possible but gives a less compressed
result.

Thanks
-- 
View this message in context: http://www.nabble.com/ZipArchiveSerializer-question-tp19082078p19082078.html
Sent from the Cocoon - Users mailing list archive at Nabble.com.


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


RE: ZipArchiveSerializer question

Posted by Steve Cameron <st...@utas.edu.au>.
Currently Cocoon 2.1.11, I should upgrade to 2.2 though.


Alfred Nathaniel wrote:
> 
> On Mon, 2008-08-25 at 17:44 -0700, Steve Cameron wrote:
>> Thanks Jasha,
>> 
>> Adding the attribute mime-type="application/zip" to the <map:serialize
>> type="zip"/> fixes the problem!
>> 
>> However, it is already in the in the main sitemap.xmap:
>> 
>>  <map:serializer logger="sitemap.serializer.zip"
>> mime-type="application/zip"
>> name="zip" src="org.apache.cocoon.serialization.ZipArchiveSerializer"/>
>> 
>> So why should this be necessary?
> 
> Which version Cocoon are you using?  This sounds like you an old problem
> which was fixed in 2.1.7.
> 
> Cheers, Alfred.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/ZipArchiveSerializer-question-tp19082078p19263262.html
Sent from the Cocoon - Users mailing list archive at Nabble.com.


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


RE: ZipArchiveSerializer question

Posted by Alfred Nathaniel <an...@apache.org>.
On Mon, 2008-08-25 at 17:44 -0700, Steve Cameron wrote:
> Thanks Jasha,
> 
> Adding the attribute mime-type="application/zip" to the <map:serialize
> type="zip"/> fixes the problem!
> 
> However, it is already in the in the main sitemap.xmap:
> 
>  <map:serializer logger="sitemap.serializer.zip" mime-type="application/zip"
> name="zip" src="org.apache.cocoon.serialization.ZipArchiveSerializer"/>
> 
> So why should this be necessary?

Which version Cocoon are you using?  This sounds like you an old problem
which was fixed in 2.1.7.

Cheers, Alfred.


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


RE: ZipArchiveSerializer question

Posted by Steve Cameron <st...@utas.edu.au>.
Thanks Jasha,

Adding the attribute mime-type="application/zip" to the <map:serialize
type="zip"/> fixes the problem!

However, it is already in the in the main sitemap.xmap:

 <map:serializer logger="sitemap.serializer.zip" mime-type="application/zip"
name="zip" src="org.apache.cocoon.serialization.ZipArchiveSerializer"/>

So why should this be necessary?



Jasha Joachimsthal-2 wrote:
> 
> Hello Steve 
> 
>> -----Original Message-----
>> From: Steve Cameron [mailto:stephen.cameron@utas.edu.au] 
>> Sent: maandag 25 augustus 2008 1:46
>> To: users@cocoon.apache.org
>> Subject: Re: ZipArchiveSerializer question
>> 
>> 
>> Hello Alfred,
>> 
>> Say have a url 'http://mysite.com/cocoon/test.xml' and I want 
>> to add an option to save the same test.xml file as a zip archive.
>> 
>> I see now that if I have the following sitemap:
>> 
>> 	<map:match pattern="*.zip">
>>         <map:generate src="nothing.xml" type="file"/>
>> 	<map:transform src="zip.xsl">
>> 		<map:parameter name="source" value="{1}"/>	
>> 	</map:transform>
>>         <map:serialize type="zip"/>
>> 	</map:match>
> 
> 
>> I am directing the output of the "*" pipeline into the 
>> "*.zip" pipeline.
>> 
>> This almost seems to work, but the browser does not seem to 
>> understand that file is a zip, so maybe I'm still doing 
>> something incorrectly, thanks for your help.
>> 
>> Steve Cameron
> 
> Have you defined a mime-type for the zip-serializer?
> If not, try adding the attribute mime-type="application/zip" to either
> <map:serialize type="zip"/> in your pipeline or to the <map:serializer
> name="zip"/> in map:components. 
> 
> Jasha Joachimsthal 
> 
> www.onehippo.com
> Amsterdam - Hippo B.V. Oosteinde 11 1017 WT Amsterdam +31(0)20-5224466 
> San Francisco - Hippo USA Inc. 101 H Street, suite Q Petaluma CA
> 94952-3329 +1 (707) 773-4646
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/ZipArchiveSerializer-question-tp19082078p19154099.html
Sent from the Cocoon - Users mailing list archive at Nabble.com.


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


RE: ZipArchiveSerializer question

Posted by Jasha Joachimsthal <j....@onehippo.com>.
Hello Steve 

> -----Original Message-----
> From: Steve Cameron [mailto:stephen.cameron@utas.edu.au] 
> Sent: maandag 25 augustus 2008 1:46
> To: users@cocoon.apache.org
> Subject: Re: ZipArchiveSerializer question
> 
> 
> Hello Alfred,
> 
> Say have a url 'http://mysite.com/cocoon/test.xml' and I want 
> to add an option to save the same test.xml file as a zip archive.
> 
> I see now that if I have the following sitemap:
> 
> 	<map:match pattern="*.zip">
>         <map:generate src="nothing.xml" type="file"/>
> 	<map:transform src="zip.xsl">
> 		<map:parameter name="source" value="{1}"/>	
> 	</map:transform>
>         <map:serialize type="zip"/>
> 	</map:match>


> I am directing the output of the "*" pipeline into the 
> "*.zip" pipeline.
> 
> This almost seems to work, but the browser does not seem to 
> understand that file is a zip, so maybe I'm still doing 
> something incorrectly, thanks for your help.
> 
> Steve Cameron

Have you defined a mime-type for the zip-serializer?
If not, try adding the attribute mime-type="application/zip" to either
<map:serialize type="zip"/> in your pipeline or to the <map:serializer
name="zip"/> in map:components. 

Jasha Joachimsthal 

www.onehippo.com
Amsterdam - Hippo B.V. Oosteinde 11 1017 WT Amsterdam +31(0)20-5224466 
San Francisco - Hippo USA Inc. 101 H Street, suite Q Petaluma CA
94952-3329 +1 (707) 773-4646


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


Re: ZipArchiveSerializer question

Posted by Steve Cameron <st...@utas.edu.au>.
Hello Alfred,

Say have a url 'http://mysite.com/cocoon/test.xml' and I want to add an
option to save the same test.xml file as a zip archive.

I see now that if I have the following sitemap:

	<map:match pattern="*.zip">
        <map:generate src="nothing.xml" type="file"/>
	<map:transform src="zip.xsl">
		<map:parameter name="source" value="{1}"/>	
	</map:transform>
        <map:serialize type="zip"/>
	</map:match>

      <map:match pattern="*">
        <map:generate src="{1}.xml"/>
        <map:serialize type="xml"/>
	</map:match 

Where nothing.xml is effectively an empty xml file having only <xml></xml>
tags.

And the zip.xsl is as follows:

<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns="http://mine">
  <xsl:param name="source"/>
  <xsl:template match="/">
	  <zip:archive xmlns:zip="http://apache.org/cocoon/zip-archive/1.0">
		<zip:entry>
			<xsl:attribute name="name"><xsl:value-of
select="$source"/></xsl:attribute>
			<xsl:attribute name="src">cocoon:/<xsl:value-of
select="$source"/></xsl:attribute>
	  	</zip:entry>
          </zip:archive>
  </xsl:template>
</xsl:stylesheet>

I am directing the output of the "*" pipeline into the "*.zip" pipeline.

This almost seems to work, but the browser does not seem to understand that
file is a zip, so maybe I'm still doing something incorrectly, thanks for
your help.

Steve Cameron



Alfred Nathaniel wrote:
> 
> On Wed, 2008-08-20 at 20:54 -0700, Steve Cameron wrote:
>> Hello,
>> 
>> Is it possible to use the ZipArchiveSerializer and process the generator
>> output straight off without sending it to a disk file first?
>> 
>> I think this stream compression is possible but gives a less compressed
>> result.
> 
> I don't quite understand what your question is.
> 
> The ZIPArchiveSerializer does not write any on-disk ZIP file.  It
> buffers in memory and streams it to the HTTP response.
> 
> If you on the client side don't want to store the ZIP file, you can
> unpack it immediately:
> 
>     curl http://... | jar xfv -
> 
> HTH, Alfred.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/ZipArchiveSerializer-question-tp19082078p19136064.html
Sent from the Cocoon - Users mailing list archive at Nabble.com.


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


Re: ZipArchiveSerializer question

Posted by Alfred Nathaniel <an...@apache.org>.
On Wed, 2008-08-20 at 20:54 -0700, Steve Cameron wrote:
> Hello,
> 
> Is it possible to use the ZipArchiveSerializer and process the generator
> output straight off without sending it to a disk file first?
> 
> I think this stream compression is possible but gives a less compressed
> result.

I don't quite understand what your question is.

The ZIPArchiveSerializer does not write any on-disk ZIP file.  It
buffers in memory and streams it to the HTTP response.

If you on the client side don't want to store the ZIP file, you can
unpack it immediately:

    curl http://... | jar xfv -

HTH, Alfred.


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