Transform Directly Into a Zip File?

classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|

Transform Directly Into a Zip File?

Eliot Kimber-2
I'm implementing a transformation that runs within a Web service and
produces a DITA map and topics. The Web service returns a Zip file.

My question: what would be involved in order to transform directly into
the Zip file, rather than generating files and then zipping those?

Right now my transform takes an "outdir" parameter that specifies the base
URI to write result files to (using xsl:result-document).

A quick search on "saxon transform to zip file" didn't reveal anything but
surely somebody has already done this?

If I was just generating a single result document it would be easy: just
set the Zip output stream as the destination stream, but since I'm
generating multiple results I'm not sure how I would handle that.

If there's no ready code lying about I think I just need to be pointed in
the right direction and I can puzzle out the rest.

Thanks,

Eliot

----
Eliot Kimber, Owner
Contrext, LLC
http://contrext.com




------------------------------------------------------------------------------
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Transform Directly Into a Zip File?

John Lumley-2
Eliot,

Saxon9.6 PE/EE implements the EXPath Archive module to a reasonable extent, so it should be possible to arrange ZIP construction with some suitable marshalling of results to a series of extension calls.

Note that the EXPath Archive spec hasn't been finalised - there are some outstanding issues about how options and meta-info is specified. But there should be sufficient documentation within Saxon http://www.saxonica.com/documentation/index.html#!functions/expath-archive and EXPath http://expath.org/spec/archive to give you a hope.


John

On 08/10/2015 16:46, Eliot Kimber wrote:
I'm implementing a transformation that runs within a Web service and
produces a DITA map and topics. The Web service returns a Zip file.

My question: what would be involved in order to transform directly into
the Zip file, rather than generating files and then zipping those?

Right now my transform takes an "outdir" parameter that specifies the base
URI to write result files to (using xsl:result-document).

A quick search on "saxon transform to zip file" didn't reveal anything but
surely somebody has already done this?

If I was just generating a single result document it would be easy: just
set the Zip output stream as the destination stream, but since I'm
generating multiple results I'm not sure how I would handle that.

If there's no ready code lying about I think I just need to be pointed in
the right direction and I can puzzle out the rest.

Thanks,

Eliot

--
John Lumley MA PhD CEng FIEE
[hidden email]
on behalf of Saxonica Ltd

------------------------------------------------------------------------------

_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Transform Directly Into a Zip File?

Earl Hood-3
On Thu, Oct 8, 2015 at 11:14 AM, John Lumley wrote:

> Saxon9.6 PE/EE implements the EXPath Archive module to a reasonable extent,
> so it should be possible to arrange ZIP construction with some suitable
> marshalling of results to a series of extension calls.
...

Does, or can, Saxon work with Java's file system framework:

<http://docs.oracle.com/javase/7/docs/technotes/guides/io/fsp/zipfilesystemprovider.html>

--ewh

------------------------------------------------------------------------------
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Transform Directly Into a Zip File?

Lizzi, Vincent
In reply to this post by Eliot Kimber-2

Hi Eliot,

 

I’ve used the Archive module in BaseX (which uses Saxon) to read and output Zip files in a transformation. There’s also an EXPath Zip module. Maybe this will be of some use to you.

 

http://docs.basex.org/wiki/Archive_Module

http://docs.basex.org/wiki/ZIP_Module

http://expath.org/spec/zip

 

Are you hoping to output a zip file directly from Saxon?

 

Cheers,

Vincent

 

 

 

From: Eliot Kimber [mailto:[hidden email]]
Sent: Thursday, October 08, 2015 11:46 AM
To: Mailing list for the SAXON XSLT and XQuery processor <[hidden email]>
Subject: [saxon] Transform Directly Into a Zip File?

 

I'm implementing a transformation that runs within a Web service and
produces a DITA map and topics. The Web service returns a Zip file.

My question: what would be involved in order to transform directly into
the Zip file, rather than generating files and then zipping those?

Right now my transform takes an "outdir" parameter that specifies the base
URI to write result files to (using xsl:result-document).

A quick search on "saxon transform to zip file" didn't reveal anything but
surely somebody has already done this?

If I was just generating a single result document it would be easy: just
set the Zip output stream as the destination stream, but since I'm
generating multiple results I'm not sure how I would handle that.

If there's no ready code lying about I think I just need to be pointed in
the right direction and I can puzzle out the rest.

Thanks,

Eliot

----
Eliot Kimber, Owner
Contrext, LLC
http://contrext.com




------------------------------------------------------------------------------
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help


------------------------------------------------------------------------------

_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Transform Directly Into a Zip File?

Eliot Kimber-2
In reply to this post by John Lumley-2
John,

I had no idea. I'll give it a shot.

Cheers,

E.
----
Eliot Kimber, Owner
Contrext, LLC
http://contrext.com




On 10/8/15, 11:14 AM, "John Lumley" <[hidden email]> wrote:

>
>  
>    
>  
>  
>    Eliot,
>      
>      Saxon9.6 PE/EE implements the EXPath Archive module to a
>      reasonable extent, so it should be possible to arrange ZIP
>      construction with some suitable marshalling of results to a series
>      of extension calls.
>      
>      Note that the EXPath Archive spec hasn't been finalised - there
>      are some outstanding issues about how options and meta-info is
>      specified. But there should be sufficient documentation within
>      Saxon  
><http://www.saxonica.com/documentation/index.html#%21functions/expath-arch
>ive>http://www.saxonica.com/documentation/index.html#!functions/expath-arc
>hive
>      and EXPath http://expath.org/spec/archive
>      to give you a hope.
>      
>      
>      John
>      
>      On 08/10/2015 16:46, Eliot Kimber wrote:
>    
>    
>      I'm implementing a transformation that runs within a Web service and
>produces a DITA map and topics. The Web service returns a Zip file.
>
>My question: what would be involved in order to transform directly into
>the Zip file, rather than generating files and then zipping those?
>
>Right now my transform takes an "outdir" parameter that specifies the base
>URI to write result files to (using xsl:result-document).
>
>A quick search on "saxon transform to zip file" didn't reveal anything but
>surely somebody has already done this?
>
>If I was just generating a single result document it would be easy: just
>set the Zip output stream as the destination stream, but since I'm
>generating multiple results I'm not sure how I would handle that.
>
>If there's no ready code lying about I think I just need to be pointed in
>the right direction and I can puzzle out the rest.
>
>Thanks,
>
>Eliot
>    
>
>    
>    --
>      John Lumley MA PhD CEng FIEE
>      [hidden email]
>      
>      on behalf of Saxonica Ltd
>  
>
>--------------------------------------------------------------------------
>----
>_______________________________________________
>saxon-help mailing list archived at http://saxon.markmail.org/
>[hidden email]
>https://lists.sourceforge.net/lists/listinfo/saxon-help 



------------------------------------------------------------------------------
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Transform Directly Into a Zip File?

John Lumley-2
In reply to this post by Earl Hood-3
On 08/10/2015 17:30, Earl Hood wrote:
On Thu, Oct 8, 2015 at 11:14 AM, John Lumley wrote:

> Saxon9.6 PE/EE implements the EXPath Archive module to a reasonable extent,
> so it should be possible to arrange ZIP construction with some suitable
> marshalling of results to a series of extension calls.
...

Does, or can, Saxon work with Java's file system framework:

<http://docs.oracle.com/javase/7/docs/technotes/guides/io/fsp/zipfilesystemprovider.html>

--ewh
Again, file manipulation can be exploited through EXPath File http://expath.org/spec/file/1.0, which is supported quite well in Saxon 9.6 PE/EE http://www.saxonica.com/documentation/index.html#!functions/expath-file

--
John Lumley MA PhD CEng FIEE
[hidden email]
on behalf of Saxonica Ltd

------------------------------------------------------------------------------

_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Transform Directly Into a Zip File?

Michael Kay
In reply to this post by Eliot Kimber-2
Another possible design would be to implement an OutputURIResolver which accepts xsl:result-document requests and somehow maps them to OutputStreams targeted at a ZIP container, using the ZIP file support in Java to underpin this.

Michael Kay
Saxonica

NOTE: (Vincent Lizzi) I’m not aware of any common code between BaseX and Saxon. Even the EXPath modules are independent implementations.



> On 8 Oct 2015, at 16:46, Eliot Kimber <[hidden email]> wrote:
>
> I'm implementing a transformation that runs within a Web service and
> produces a DITA map and topics. The Web service returns a Zip file.
>
> My question: what would be involved in order to transform directly into
> the Zip file, rather than generating files and then zipping those?
>
> Right now my transform takes an "outdir" parameter that specifies the base
> URI to write result files to (using xsl:result-document).
>
> A quick search on "saxon transform to zip file" didn't reveal anything but
> surely somebody has already done this?
>
> If I was just generating a single result document it would be easy: just
> set the Zip output stream as the destination stream, but since I'm
> generating multiple results I'm not sure how I would handle that.
>
> If there's no ready code lying about I think I just need to be pointed in
> the right direction and I can puzzle out the rest.
>
> Thanks,
>
> Eliot
>
> ----
> Eliot Kimber, Owner
> Contrext, LLC
> http://contrext.com
>
>
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help 


------------------------------------------------------------------------------
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Transform Directly Into a Zip File?

Earl Hood
In reply to this post by John Lumley-2
On Thu, Oct 8, 2015 at 12:02 PM, John Lumley wrote:

> Does, or can, Saxon work with Java's file system framework:
>
> <http://docs.oracle.com/javase/7/docs/technotes/guides/io/fsp/zipfilesystemprovider.html>

> Again, file manipulation can be exploited through EXPath File
> http://expath.org/spec/file/1.0, which is supported quite well in Saxon 9.6
> PE/EE
> http://www.saxonica.com/documentation/index.html#!functions/expath-file

But that is not what was originally asked.

IIRC, what was asked is if <xsl:result-document> can be used to write a
result tree to an entry into a zip file.  The XSLT code is not burdened
by the underly storage system.

What is not clear from EXPath is if the underlying file system is
abstracted or not.  I see nothing that provides an abstraction layer,
i.e. the ability to define custom file system providers (like Java 7
does).  Maybe that is outside the scope of the specification.

Does Saxon provide the capability to register a "file system" into it so
the the expath-file calls actually operate directly against the zip
file?

If Saxon's implementation of expath-file leverages Java's NIO and
FileSystem, then it may be possible to operate against a zip file w/o
specific coding in the XSLT code.

--ewh

------------------------------------------------------------------------------
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Transform Directly Into a Zip File?

John Lumley-2


> On 8 Oct 2015, at 18:44, Earl Hood <[hidden email]> wrote:
>
> What is not clear from EXPath is if the underlying file system is
> abstracted or not.  I see nothing that provides an abstraction layer,
> i.e. the ability to define custom file system providers (like Java 7
> does).  Maybe that is outside the scope of the specification.

There was, to my knowledge, no abstraction inherent within the spec., save the notion of files, directories, paths etc, and binary and text-decoded transfers.

>
> Does Saxon provide the capability to register a "file system" into it so
> the the expath-file calls actually operate directly against the zip
> file?

Certainly the expath-file implementation in Saxon attaches directly to the underlying Java File classes and there should be no possiblity of introducing an indirection layer.

John
------------------------------------------------------------------------------
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Transform Directly Into a Zip File?

Eliot Kimber-2
In reply to this post by Michael Kay
If the EXPath stuff is only available in PE and EE then it's not an option
at the moment as I'm limited to HE for now.

It sounds like OutputURIResolver is the ticket here--if I knew about that
I had forgotten about it.

Cheers,

Eliot
----
Eliot Kimber, Owner
Contrext, LLC
http://contrext.com




On 10/8/15, 12:42 PM, "Michael Kay" <[hidden email]> wrote:

>Another possible design would be to implement an OutputURIResolver which
>accepts xsl:result-document requests and somehow maps them to
>OutputStreams targeted at a ZIP container, using the ZIP file support in
>Java to underpin this.
>
>Michael Kay
>Saxonica
>
>NOTE: (Vincent Lizzi) I¹m not aware of any common code between BaseX and
>Saxon. Even the EXPath modules are independent implementations.
>
>
>
>> On 8 Oct 2015, at 16:46, Eliot Kimber <[hidden email]> wrote:
>>
>> I'm implementing a transformation that runs within a Web service and
>> produces a DITA map and topics. The Web service returns a Zip file.
>>
>> My question: what would be involved in order to transform directly into
>> the Zip file, rather than generating files and then zipping those?
>>
>> Right now my transform takes an "outdir" parameter that specifies the
>>base
>> URI to write result files to (using xsl:result-document).
>>
>> A quick search on "saxon transform to zip file" didn't reveal anything
>>but
>> surely somebody has already done this?
>>
>> If I was just generating a single result document it would be easy: just
>> set the Zip output stream as the destination stream, but since I'm
>> generating multiple results I'm not sure how I would handle that.
>>
>> If there's no ready code lying about I think I just need to be pointed
>>in
>> the right direction and I can puzzle out the rest.
>>
>> Thanks,
>>
>> Eliot
>>
>> ----
>> Eliot Kimber, Owner
>> Contrext, LLC
>> http://contrext.com
>>
>>
>>
>>
>>
>>-------------------------------------------------------------------------
>>-----
>> _______________________________________________
>> saxon-help mailing list archived at http://saxon.markmail.org/
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/saxon-help
>
>
>--------------------------------------------------------------------------
>----
>_______________________________________________
>saxon-help mailing list archived at http://saxon.markmail.org/
>[hidden email]
>https://lists.sourceforge.net/lists/listinfo/saxon-help 



------------------------------------------------------------------------------
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Transform Directly Into a Zip File?

George Cristian Bina-2
Hi Eliot,

It should be possible to write directly into the zip file if you have an
URL that points to the file within the archive and that supports write
and use that in the result-document function.
We implement support for zip:/... URLs in oXygen and thus it is possible
to generate a result document directly within an archive. We have an
example in the oXygen samples project, within the ooxml folder see the
importToExcel.xsl - this basically injects a files within an Excel file
(xlsx) to update a chart with data read from an XML file. The example is
presented/explained in a short video demo at:
http://oxygenxml.com/demo/Export_to_Excel.html

Java already has jar:/... URL support that allows reading from within an
archive but I am not sure if that supports writing as well.

Best Regards,
George
--
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

On 08/10/15 21:23, Eliot Kimber wrote:

> If the EXPath stuff is only available in PE and EE then it's not an option
> at the moment as I'm limited to HE for now.
>
> It sounds like OutputURIResolver is the ticket here--if I knew about that
> I had forgotten about it.
>
> Cheers,
>
> Eliot
> ----
> Eliot Kimber, Owner
> Contrext, LLC
> http://contrext.com
>
>
>
>
> On 10/8/15, 12:42 PM, "Michael Kay" <[hidden email]> wrote:
>
>> Another possible design would be to implement an OutputURIResolver which
>> accepts xsl:result-document requests and somehow maps them to
>> OutputStreams targeted at a ZIP container, using the ZIP file support in
>> Java to underpin this.
>>
>> Michael Kay
>> Saxonica
>>
>> NOTE: (Vincent Lizzi) I¹m not aware of any common code between BaseX and
>> Saxon. Even the EXPath modules are independent implementations.
>>
>>
>>
>>> On 8 Oct 2015, at 16:46, Eliot Kimber <[hidden email]> wrote:
>>>
>>> I'm implementing a transformation that runs within a Web service and
>>> produces a DITA map and topics. The Web service returns a Zip file.
>>>
>>> My question: what would be involved in order to transform directly into
>>> the Zip file, rather than generating files and then zipping those?
>>>
>>> Right now my transform takes an "outdir" parameter that specifies the
>>> base
>>> URI to write result files to (using xsl:result-document).
>>>
>>> A quick search on "saxon transform to zip file" didn't reveal anything
>>> but
>>> surely somebody has already done this?
>>>
>>> If I was just generating a single result document it would be easy: just
>>> set the Zip output stream as the destination stream, but since I'm
>>> generating multiple results I'm not sure how I would handle that.
>>>
>>> If there's no ready code lying about I think I just need to be pointed
>>> in
>>> the right direction and I can puzzle out the rest.
>>>
>>> Thanks,
>>>
>>> Eliot
>>>
>>> ----
>>> Eliot Kimber, Owner
>>> Contrext, LLC
>>> http://contrext.com
>>>
>>>
>>>
>>>
>>>
>>> -------------------------------------------------------------------------
>>> -----
>>> _______________________________________________
>>> saxon-help mailing list archived at http://saxon.markmail.org/
>>> [hidden email]
>>> https://lists.sourceforge.net/lists/listinfo/saxon-help
>>
>>
>> --------------------------------------------------------------------------
>> ----
>> _______________________________________________
>> saxon-help mailing list archived at http://saxon.markmail.org/
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/saxon-help
>
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help
>

------------------------------------------------------------------------------
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Transform Directly Into a Zip File?

Eliot Kimber-2
In reply to this post by Michael Kay
The "Somehow maps" bit is where I'm getting tripped up.

An OutputURIResolver returns a Result instance, so I need to create a
Result that can write to a Zip stream. However, it looks like Result
instances handle the low-level events but all I really need is the
serialized result.

So there appears to be a mismatch between Result and Destination and no
obvious way to easily implement a Result that writes to the Zip stream.

Have I missed something in the API?

So maybe George's approach of using a URI handler is the best one.

For now I'm just working with files because that's easy, if not very
elegant.

Cheers,

E.

----
Eliot Kimber, Owner
Contrext, LLC
http://contrext.com




On 10/8/15, 12:42 PM, "Michael Kay" <[hidden email]> wrote:

>Another possible design would be to implement an OutputURIResolver which
>accepts xsl:result-document requests and somehow maps them to
>OutputStreams targeted at a ZIP container, using the ZIP file support in
>Java to underpin this.
>
>Michael Kay
>Saxonica
>
>NOTE: (Vincent Lizzi) I¹m not aware of any common code between BaseX and
>Saxon. Even the EXPath modules are independent implementations.
>
>
>
>> On 8 Oct 2015, at 16:46, Eliot Kimber <[hidden email]> wrote:
>>
>> I'm implementing a transformation that runs within a Web service and
>> produces a DITA map and topics. The Web service returns a Zip file.
>>
>> My question: what would be involved in order to transform directly into
>> the Zip file, rather than generating files and then zipping those?
>>
>> Right now my transform takes an "outdir" parameter that specifies the
>>base
>> URI to write result files to (using xsl:result-document).
>>
>> A quick search on "saxon transform to zip file" didn't reveal anything
>>but
>> surely somebody has already done this?
>>
>> If I was just generating a single result document it would be easy: just
>> set the Zip output stream as the destination stream, but since I'm
>> generating multiple results I'm not sure how I would handle that.
>>
>> If there's no ready code lying about I think I just need to be pointed
>>in
>> the right direction and I can puzzle out the rest.
>>
>> Thanks,
>>
>> Eliot
>>
>> ----
>> Eliot Kimber, Owner
>> Contrext, LLC
>> http://contrext.com
>>
>>
>>
>>
>>
>>-------------------------------------------------------------------------
>>-----
>> _______________________________________________
>> saxon-help mailing list archived at http://saxon.markmail.org/
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/saxon-help
>
>
>--------------------------------------------------------------------------
>----
>_______________________________________________
>saxon-help mailing list archived at http://saxon.markmail.org/
>[hidden email]
>https://lists.sourceforge.net/lists/listinfo/saxon-help 



------------------------------------------------------------------------------
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Transform Directly Into a Zip File?

Imsieke, Gerrit, le-tex
In reply to this post by Eliot Kimber-2
Have you considered using XProc and XML Calabash which includes a zip
extension step [1]? I set up an annotated example in a gist at [2].

Calabash includes Saxon HE as its XSLT processor (and for other things)
so I hope that this post on the Saxon mailing list is acceptable.

In the example [2], the main XSLT template iterates over a sequence of
integer numbers, (1 to 4), creating 4 small documents in memory. They
will then be added to a freshly created zip file. With the pxp:zip step,
you can also update existing zip files.

The output of the step given in [2] looks like (4 documents, manifest,
zip contents):

<doc>This is doc #1</doc>
<doc>This is doc #2</doc>
<doc>This is doc #3</doc>
<doc>This is doc #4</doc>
<c:zip-manifest xmlns:c="http://www.w3.org/ns/xproc-step">
  <c:entry name="path/doc1.xml" href="file://path/doc1.xml"/>
  <c:entry name="path/doc2.xml" href="file://path/doc2.xml"/>
  <c:entry name="path/doc3.xml" href="file://path/doc3.xml"/>
  <c:entry name="path/doc4.xml" href="file://path/doc4.xml"/>
</c:zip-manifest>
<c:zipfile xmlns:c="http://www.w3.org/ns/xproc-step"
           href="file:/…/out.zip">
   <c:file compressed-size="-1" size="-1"
           name="path/doc1.xml"
           date="2015-10-08T22:57:32.000+02:00"/>
   <c:file compressed-size="-1" size="-1"
           name="path/doc2.xml"
           date="2015-10-08T22:57:32.000+02:00"/>
   <c:file compressed-size="-1" size="-1"
           name="path/doc3.xml"
           date="2015-10-08T22:57:32.000+02:00"/>
   <c:file compressed-size="-1" size="-1"
           name="path/doc4.xml"
           date="2015-10-08T22:57:32.000+02:00"/>
</c:zipfile>

Here’s the zip file contents:

$ unzip -lv out.zip
Archive:  out.zip
 Length   Method    Size  Cmpr    Date    Time   CRC-32   Name
--------  ------  ------- ---- ---------- ----- --------  ----
      63  Defl:N       60   5% 10-08-2015 22:57 89d2fcf5  path/doc1.xml
      63  Defl:N       60   5% 10-08-2015 22:57 b83ae668  path/doc2.xml
      63  Defl:N       60   5% 10-08-2015 22:57 1e4deddc  path/doc3.xml
      63  Defl:N       60   5% 10-08-2015 22:57 dbead352  path/doc4.xml
--------          -------  ---                            -------
     252              240   5%                            4 files

Try XProc. It’s just like XML and XSLT: Looks simple in the beginning,
has a surprisingly steep learning curve and then is a constant source of
both joy and sometimes also bewilderment. After 6–12 months of training
and many setbacks, you will notice the sublime feeling of mastery –
provided that you stick to it. If you do, you might even start
evangelizing after 2 years. I’ve been doing XProc for 4 years now (and
XSLT for 7 – I skipped XSLT 1 altogether and started with XSLT 2 and
Saxon 8.9). I’m evangelizing for both, modern XSLT and XProc. In case
you didn’t notice.

Gerrit

[1] http://exproc.org/proposed/steps/other.html#zip
[2] https://gist.github.com/gimsieke/209341895897cad40611

On 08.10.2015 20:23, Eliot Kimber wrote:

> If the EXPath stuff is only available in PE and EE then it's not an option
> at the moment as I'm limited to HE for now.
>
> It sounds like OutputURIResolver is the ticket here--if I knew about that
> I had forgotten about it.
>
> Cheers,
>
> Eliot
> ----
> Eliot Kimber, Owner
> Contrext, LLC
> http://contrext.com
>
>
>
>
> On 10/8/15, 12:42 PM, "Michael Kay" <[hidden email]> wrote:
>
>> Another possible design would be to implement an OutputURIResolver which
>> accepts xsl:result-document requests and somehow maps them to
>> OutputStreams targeted at a ZIP container, using the ZIP file support in
>> Java to underpin this.
>>
>> Michael Kay
>> Saxonica
>>
>> NOTE: (Vincent Lizzi) I¹m not aware of any common code between BaseX and
>> Saxon. Even the EXPath modules are independent implementations.
>>
>>
>>
>>> On 8 Oct 2015, at 16:46, Eliot Kimber <[hidden email]> wrote:
>>>
>>> I'm implementing a transformation that runs within a Web service and
>>> produces a DITA map and topics. The Web service returns a Zip file.
>>>
>>> My question: what would be involved in order to transform directly into
>>> the Zip file, rather than generating files and then zipping those?
>>>
>>> Right now my transform takes an "outdir" parameter that specifies the
>>> base
>>> URI to write result files to (using xsl:result-document).
>>>
>>> A quick search on "saxon transform to zip file" didn't reveal anything
>>> but
>>> surely somebody has already done this?
>>>
>>> If I was just generating a single result document it would be easy: just
>>> set the Zip output stream as the destination stream, but since I'm
>>> generating multiple results I'm not sure how I would handle that.
>>>
>>> If there's no ready code lying about I think I just need to be pointed
>>> in
>>> the right direction and I can puzzle out the rest.
>>>
>>> Thanks,
>>>
>>> Eliot

------------------------------------------------------------------------------
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Transform Directly Into a Zip File?

Eliot Kimber-2
This is in the context of an otherwise simple Java Web service, so XProc
and Calabash are not really needed here.

At this point, I have a file-based solution working, so generating the Zip
directly would be a refinement but not a material improvement to the
current process. It's not one where high throughput is a requirement.

Cheers,

Eliot
----
Eliot Kimber, Owner
Contrext, LLC
http://contrext.com




On 10/8/15, 4:31 PM, "Imsieke, Gerrit, le-tex" <[hidden email]>
wrote:

>Have you considered using XProc and XML Calabash which includes a zip
>extension step [1]? I set up an annotated example in a gist at [2].
>
>Calabash includes Saxon HE as its XSLT processor (and for other things)
>so I hope that this post on the Saxon mailing list is acceptable.
>
>In the example [2], the main XSLT template iterates over a sequence of
>integer numbers, (1 to 4), creating 4 small documents in memory. They
>will then be added to a freshly created zip file. With the pxp:zip step,
>you can also update existing zip files.
>
>The output of the step given in [2] looks like (4 documents, manifest,
>zip contents):
>
><doc>This is doc #1</doc>
><doc>This is doc #2</doc>
><doc>This is doc #3</doc>
><doc>This is doc #4</doc>
><c:zip-manifest xmlns:c="http://www.w3.org/ns/xproc-step">
>  <c:entry name="path/doc1.xml" href="file://path/doc1.xml"/>
>  <c:entry name="path/doc2.xml" href="file://path/doc2.xml"/>
>  <c:entry name="path/doc3.xml" href="file://path/doc3.xml"/>
>  <c:entry name="path/doc4.xml" href="file://path/doc4.xml"/>
></c:zip-manifest>
><c:zipfile xmlns:c="http://www.w3.org/ns/xproc-step"
>           href="file:/…/out.zip">
>   <c:file compressed-size="-1" size="-1"
>           name="path/doc1.xml"
>           date="2015-10-08T22:57:32.000+02:00"/>
>   <c:file compressed-size="-1" size="-1"
>           name="path/doc2.xml"
>           date="2015-10-08T22:57:32.000+02:00"/>
>   <c:file compressed-size="-1" size="-1"
>           name="path/doc3.xml"
>           date="2015-10-08T22:57:32.000+02:00"/>
>   <c:file compressed-size="-1" size="-1"
>           name="path/doc4.xml"
>           date="2015-10-08T22:57:32.000+02:00"/>
></c:zipfile>
>
>Here’s the zip file contents:
>
>$ unzip -lv out.zip
>Archive:  out.zip
> Length   Method    Size  Cmpr    Date    Time   CRC-32   Name
>--------  ------  ------- ---- ---------- ----- --------  ----
>      63  Defl:N       60   5% 10-08-2015 22:57 89d2fcf5  path/doc1.xml
>      63  Defl:N       60   5% 10-08-2015 22:57 b83ae668  path/doc2.xml
>      63  Defl:N       60   5% 10-08-2015 22:57 1e4deddc  path/doc3.xml
>      63  Defl:N       60   5% 10-08-2015 22:57 dbead352  path/doc4.xml
>--------          -------  ---                            -------
>     252              240   5%                            4 files
>
>Try XProc. It’s just like XML and XSLT: Looks simple in the beginning,
>has a surprisingly steep learning curve and then is a constant source of
>both joy and sometimes also bewilderment. After 6­12 months of training
>and many setbacks, you will notice the sublime feeling of mastery ­
>provided that you stick to it. If you do, you might even start
>evangelizing after 2 years. I’ve been doing XProc for 4 years now (and
>XSLT for 7 ­ I skipped XSLT 1 altogether and started with XSLT 2 and
>Saxon 8.9). I’m evangelizing for both, modern XSLT and XProc. In case
>you didn’t notice.
>
>Gerrit
>
>[1] http://exproc.org/proposed/steps/other.html#zip
>[2] https://gist.github.com/gimsieke/209341895897cad40611
>
>On 08.10.2015 20:23, Eliot Kimber wrote:
>> If the EXPath stuff is only available in PE and EE then it's not an
>>option
>> at the moment as I'm limited to HE for now.
>>
>> It sounds like OutputURIResolver is the ticket here--if I knew about
>>that
>> I had forgotten about it.
>>
>> Cheers,
>>
>> Eliot
>> ----
>> Eliot Kimber, Owner
>> Contrext, LLC
>> http://contrext.com
>>
>>
>>
>>
>> On 10/8/15, 12:42 PM, "Michael Kay" <[hidden email]> wrote:
>>
>>> Another possible design would be to implement an OutputURIResolver
>>>which
>>> accepts xsl:result-document requests and somehow maps them to
>>> OutputStreams targeted at a ZIP container, using the ZIP file support
>>>in
>>> Java to underpin this.
>>>
>>> Michael Kay
>>> Saxonica
>>>
>>> NOTE: (Vincent Lizzi) I¹m not aware of any common code between BaseX
>>>and
>>> Saxon. Even the EXPath modules are independent implementations.
>>>
>>>
>>>
>>>> On 8 Oct 2015, at 16:46, Eliot Kimber <[hidden email]> wrote:
>>>>
>>>> I'm implementing a transformation that runs within a Web service and
>>>> produces a DITA map and topics. The Web service returns a Zip file.
>>>>
>>>> My question: what would be involved in order to transform directly
>>>>into
>>>> the Zip file, rather than generating files and then zipping those?
>>>>
>>>> Right now my transform takes an "outdir" parameter that specifies the
>>>> base
>>>> URI to write result files to (using xsl:result-document).
>>>>
>>>> A quick search on "saxon transform to zip file" didn't reveal anything
>>>> but
>>>> surely somebody has already done this?
>>>>
>>>> If I was just generating a single result document it would be easy:
>>>>just
>>>> set the Zip output stream as the destination stream, but since I'm
>>>> generating multiple results I'm not sure how I would handle that.
>>>>
>>>> If there's no ready code lying about I think I just need to be pointed
>>>> in
>>>> the right direction and I can puzzle out the rest.
>>>>
>>>> Thanks,
>>>>
>>>> Eliot
>
>--------------------------------------------------------------------------
>----
>_______________________________________________
>saxon-help mailing list archived at http://saxon.markmail.org/
>[hidden email]
>https://lists.sourceforge.net/lists/listinfo/saxon-help 



------------------------------------------------------------------------------
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Transform Directly Into a Zip File?

Michael Kay
In reply to this post by Eliot Kimber-2
If you can create an OutputStream that writes to a Zip file, then you can wrap it in a StreamResult and return it from the OutputURIResolver.

Michael Kay
Saxonica

> On 8 Oct 2015, at 22:14, Eliot Kimber <[hidden email]> wrote:
>
> The "Somehow maps" bit is where I'm getting tripped up.
>
> An OutputURIResolver returns a Result instance, so I need to create a
> Result that can write to a Zip stream. However, it looks like Result
> instances handle the low-level events but all I really need is the
> serialized result.
>
> So there appears to be a mismatch between Result and Destination and no
> obvious way to easily implement a Result that writes to the Zip stream.
>
> Have I missed something in the API?
>
> So maybe George's approach of using a URI handler is the best one.
>
> For now I'm just working with files because that's easy, if not very
> elegant.
>
> Cheers,
>
> E.
>
> ----
> Eliot Kimber, Owner
> Contrext, LLC
> http://contrext.com
>
>
>
>
> On 10/8/15, 12:42 PM, "Michael Kay" <[hidden email]> wrote:
>
>> Another possible design would be to implement an OutputURIResolver which
>> accepts xsl:result-document requests and somehow maps them to
>> OutputStreams targeted at a ZIP container, using the ZIP file support in
>> Java to underpin this.
>>
>> Michael Kay
>> Saxonica
>>
>> NOTE: (Vincent Lizzi) I¹m not aware of any common code between BaseX and
>> Saxon. Even the EXPath modules are independent implementations.
>>
>>
>>
>>> On 8 Oct 2015, at 16:46, Eliot Kimber <[hidden email]> wrote:
>>>
>>> I'm implementing a transformation that runs within a Web service and
>>> produces a DITA map and topics. The Web service returns a Zip file.
>>>
>>> My question: what would be involved in order to transform directly into
>>> the Zip file, rather than generating files and then zipping those?
>>>
>>> Right now my transform takes an "outdir" parameter that specifies the
>>> base
>>> URI to write result files to (using xsl:result-document).
>>>
>>> A quick search on "saxon transform to zip file" didn't reveal anything
>>> but
>>> surely somebody has already done this?
>>>
>>> If I was just generating a single result document it would be easy: just
>>> set the Zip output stream as the destination stream, but since I'm
>>> generating multiple results I'm not sure how I would handle that.
>>>
>>> If there's no ready code lying about I think I just need to be pointed
>>> in
>>> the right direction and I can puzzle out the rest.
>>>
>>> Thanks,
>>>
>>> Eliot
>>>
>>> ----
>>> Eliot Kimber, Owner
>>> Contrext, LLC
>>> http://contrext.com
>>>
>>>
>>>
>>>
>>>
>>> -------------------------------------------------------------------------
>>> -----
>>> _______________________________________________
>>> saxon-help mailing list archived at http://saxon.markmail.org/
>>> [hidden email]
>>> https://lists.sourceforge.net/lists/listinfo/saxon-help
>>
>>
>> --------------------------------------------------------------------------
>> ----
>> _______________________________________________
>> saxon-help mailing list archived at http://saxon.markmail.org/
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/saxon-help 
>
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help 


------------------------------------------------------------------------------
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Transform Directly Into a Zip File?

Eliot Kimber-2
OK, I see that I can extend StreamResult to add the connection to the Zip
output stream--it should work. I just need to hook up the output URI
resolver. Unfortunately I'm out of time for this task for the next few
days, but I don't see any reason why it shouldn't work.

Cheers,

E.
----
Eliot Kimber, Owner
Contrext, LLC
http://contrext.com




On 10/8/15, 5:57 PM, "Michael Kay" <[hidden email]> wrote:

>If you can create an OutputStream that writes to a Zip file, then you can
>wrap it in a StreamResult and return it from the OutputURIResolver.
>
>Michael Kay
>Saxonica
>
>> On 8 Oct 2015, at 22:14, Eliot Kimber <[hidden email]> wrote:
>>
>> The "Somehow maps" bit is where I'm getting tripped up.
>>
>> An OutputURIResolver returns a Result instance, so I need to create a
>> Result that can write to a Zip stream. However, it looks like Result
>> instances handle the low-level events but all I really need is the
>> serialized result.
>>
>> So there appears to be a mismatch between Result and Destination and no
>> obvious way to easily implement a Result that writes to the Zip stream.
>>
>> Have I missed something in the API?
>>
>> So maybe George's approach of using a URI handler is the best one.
>>
>> For now I'm just working with files because that's easy, if not very
>> elegant.
>>
>> Cheers,
>>
>> E.
>>
>> ----
>> Eliot Kimber, Owner
>> Contrext, LLC
>> http://contrext.com
>>
>>
>>
>>
>> On 10/8/15, 12:42 PM, "Michael Kay" <[hidden email]> wrote:
>>
>>> Another possible design would be to implement an OutputURIResolver
>>>which
>>> accepts xsl:result-document requests and somehow maps them to
>>> OutputStreams targeted at a ZIP container, using the ZIP file support
>>>in
>>> Java to underpin this.
>>>
>>> Michael Kay
>>> Saxonica
>>>
>>> NOTE: (Vincent Lizzi) I¹m not aware of any common code between BaseX
>>>and
>>> Saxon. Even the EXPath modules are independent implementations.
>>>
>>>
>>>
>>>> On 8 Oct 2015, at 16:46, Eliot Kimber <[hidden email]> wrote:
>>>>
>>>> I'm implementing a transformation that runs within a Web service and
>>>> produces a DITA map and topics. The Web service returns a Zip file.
>>>>
>>>> My question: what would be involved in order to transform directly
>>>>into
>>>> the Zip file, rather than generating files and then zipping those?
>>>>
>>>> Right now my transform takes an "outdir" parameter that specifies the
>>>> base
>>>> URI to write result files to (using xsl:result-document).
>>>>
>>>> A quick search on "saxon transform to zip file" didn't reveal anything
>>>> but
>>>> surely somebody has already done this?
>>>>
>>>> If I was just generating a single result document it would be easy:
>>>>just
>>>> set the Zip output stream as the destination stream, but since I'm
>>>> generating multiple results I'm not sure how I would handle that.
>>>>
>>>> If there's no ready code lying about I think I just need to be pointed
>>>> in
>>>> the right direction and I can puzzle out the rest.
>>>>
>>>> Thanks,
>>>>
>>>> Eliot
>>>>
>>>> ----
>>>> Eliot Kimber, Owner
>>>> Contrext, LLC
>>>> http://contrext.com
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>-----------------------------------------------------------------------
>>>>--
>>>> -----
>>>> _______________________________________________
>>>> saxon-help mailing list archived at http://saxon.markmail.org/
>>>> [hidden email]
>>>> https://lists.sourceforge.net/lists/listinfo/saxon-help
>>>
>>>
>>>
>>>------------------------------------------------------------------------
>>>--
>>> ----
>>> _______________________________________________
>>> saxon-help mailing list archived at http://saxon.markmail.org/
>>> [hidden email]
>>> https://lists.sourceforge.net/lists/listinfo/saxon-help
>>
>>
>>
>>
>>-------------------------------------------------------------------------
>>-----
>> _______________________________________________
>> saxon-help mailing list archived at http://saxon.markmail.org/
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/saxon-help
>
>
>--------------------------------------------------------------------------
>----
>_______________________________________________
>saxon-help mailing list archived at http://saxon.markmail.org/
>[hidden email]
>https://lists.sourceforge.net/lists/listinfo/saxon-help
>



------------------------------------------------------------------------------
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help