Subject: Re: Zipping xsl:result-documents into ePub
From: Martynas Jusevicius <martynas.jusevicius@xxxxxxxxx>
Date: Tue, 25 Aug 2009 17:55:22 +0200
|
Thanks Florent, EXPath worked like a charm! So far at least. I joined
the Google Group.
Maybe you have an example on reading OpenDocument (at least .odt), so
that I could drop ODFToolkit and have my whole ODF > ePub workflow as
XSLT? :)
Martynas
semantic-web.dk
On Tue, Aug 25, 2009 at 5:05 PM, Florent Georges<lists@xxxxxxxxxxxx> wrote:
> 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>
|