[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Zipping xsl:result-documents into ePub

Subject: Re: Zipping xsl:result-documents into ePub
From: Florent Georges <lists@xxxxxxxxxxxx>
Date: Tue, 25 Aug 2009 15:05:47 +0000 (GMT)
Re:  Zipping xsl:result-documents into ePub
Martynas Jusevicius wrote:

  Hi,

> However, so far I'm writing the result
documents to a folder in
> the filesystem.  As I'm planing to package them
into ePub file
> using java.util.zip, this is probably not very smart.  Is
there
> a way to avoid serializing to files and pass the result
> documents
directly to java.util.zip, probably as streams?  I
> saw OutputURIResolver
mentioned, but couldn't find a decent
> example.

  You can also have a look
at the EXPath ZIP facility.  It has
not been released yet, and is still in
development, but if you
generate (at least some of) the entries of the ZIP
file in XSLT,
it allows you to handle the creation of the ZIP file directly
from the stylesheet.  See a complete example at the end of this
message.

  As
I said, it has not been released yet, but you can find a dev
version at
http://www.expath.org/tmp/expath-zip-saxon-0.1.pkg.zip
for Saxon.  Just import
the included stylesheet in your own
stylesheet and put the JAR file into your
classpath.

  For any further info, see http://groups.google.com/group/expath
and http://www.expath.org/.

  Regards,

-- 
Florent Georges
http://www.fgeorges.org/


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:zip="http://www.expath.org/mod/zip"
xmlns="urn:oasis:names:tc:opendocument:xmlns:container"
exclude-result-prefixes="#all"
                version="2.0">

   <xsl:import
href="http://www.expath.org/mod/zip.xsl"/>

   <xsl:output
omit-xml-declaration="yes" indent="yes"/>

   <xsl:template name="main"
match="/">

      <!-- the output file name -->
      <xsl:variable
name="file" select="
          resolve-uri('simple-zip-create.zip')"/>
<!-- description of the content of the new ZIP file -->
      <xsl:variable
name="struct" as="element(zip:file)">
         <!-- the ZIP file itself -->
<zip:file href="{ $file }">
            <!-- the 'mimetype' file within the
ZIP -->
            <zip:entry name="mimetype" output="text">
<xsl:text>application/epub+zip</xsl:text>
            </zip:entry>
<!-- the 'META-INF' dir within the ZIP -->
            <zip:dir
name="META-INF">
               <!-- the 'container.xml' file within the dir
-->
               <zip:entry name="container.xml" output="xml">
<container version="1.0">
                     <rootfiles>
<rootfile full-path="..." media-type="..."/>
                     </rootfiles>
</container>
               </zip:entry>
            </zip:dir>
</zip:file>
      </xsl:variable>

      <!-- the entries in the presentation
file -->
      <xsl:sequence select="zip:zip-file($struct)"/>
</xsl:template>

</xsl:stylesheet>

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.