Hi Martin,
I suspect this is an issue of keeping import precedence straight, a
process complicated by the fact that epub3 imports stylesheet files.
Try this description of customizing epub3 and let me know if you have
better results.
Customizing the epub3 stylesheet
---------------------------------
As with all DocBook stylesheets that generate chunked output, a
customization requires two files: one for chunking behavior and
one for element formatting. Most people only need to customize
element formatting, but you still need the two files to keep the
proper import precedence. See this doc for details about this
issue:
http://www.sagehill.net/docbookxsl/ChunkingCustomization.htmlHere is an example of the chunking stylesheet, which is the one you
apply to your document when processing:
custom-epub3-chunk.xsl
--------------------------------------------------------------------
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:d="http://docbook.org/ns/docbook"
version="1.0"
exclude-result-prefixes="d">
<xsl:import href="custom-epub3-elements.xsl"/>
<xsl:import
href="http://docbook.sourceforge.net/release/xsl/current/xhtml/chunk-common.xsl"/>
<xsl:include
href="http://docbook.sourceforge.net/release/xsl/current/xhtml/chunk-code.xsl"/>
<xsl:include
href="http://docbook.sourceforge.net/release/xsl/current/epub3/epub3-chunk-mods.xsl"/>
</xsl:stylesheet>
--------------------------------------------------------------------
The following stylesheet file is imported by the above file.
custom-epub3-elements.xsl
--------------------------------------------------------------------
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:d="http://docbook.org/ns/docbook"
exclude-result-prefixes="#default d"
version="1.0">
<xsl:import
href="http://docbook.sourceforge.net/release/xsl/current/xhtml5/docbook.xsl"/>
<xsl:include
href="http://docbook.sourceforge.net/release/xsl/current/epub3/epub3-element-mods.xsl"/>
</xsl:stylesheet>
--------------------------------------------------------------------
Bob Stayton
Sagehill Enterprises
bobs@sagehill.netOn 1/24/2015 11:58 AM, Martin Doucha wrote:
> Hi,
> I'm trying to generate Epub file with autogenerated ToC in a separate
> chunk at a specific position. I've tried to follow the howto at
>
http://www.sagehill.net/docbookxsl/ChunkingCustomization.html to the
> best of my ability but no matter what I do, xsltproc just prints lots
> of I/O errors when I add customized <xsl:template name="chunk"> that
> relies on <xsl:apply-imports/>. Here's the whole minimal stylesheet
> that doesn't work. I want to add some content customizations as well
> (those should replace the first import according to the howto) but
> let's keep it simple. The imports and includes are adapted from
> epub3/chunk.xsl. Including epub3/chunk.xsl itself instead makes no
> difference.
>
>>
>> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
>> <xsl:import href="http://docbook.sourceforge.net/release/xsl-ns/current/epub3/docbook.xsl"/>
>> <xsl:import href="http://docbook.sourceforge.net/release/xsl-ns/current/xhtml/chunk-common.xsl"/>
>> <xsl:include href="http://docbook.sourceforge.net/release/xsl-ns/current/xhtml/chunk-code.xsl"/>
>> <xsl:include href="http://docbook.sourceforge.net/release/xsl-ns/current/epub3/epub3-chunk-mods.xsl"/>
>>
>> <xsl:param name="generate.toc">
>> book title
>> </xsl:param>
>> <xsl:param name="process.empty.source.toc" select="1"/>
>> <xsl:param name="process.source.toc" select="1"/>
>>
>> <xsl:template name="chunk">
>> <xsl:param name="node" select="."/>
>> <xsl:variable name="ret">
>> <xsl:choose>
>> <xsl:when test="local-name($node) = 'toc'">1</xsl:when>
>> <xsl:when test="local-name($node) = 'preface'">0</xsl:when>
>> <xsl:otherwise>
>> <xsl:apply-imports/>
>> </xsl:otherwise>
>> </xsl:choose>
>> </xsl:variable>
>> <xsl:message>
>> <xsl:text>Chunk test: </xsl:text>
>> <xsl:value-of select="local-name($node)"/>
>> <xsl:text> - </xsl:text>
>> <xsl:value-of select="$ret"/>
>> </xsl:message>
>> <xsl:value-of select="$ret"/>
>> </xsl:template>
>> </xsl:stylesheet>
>
> Notice the <xsl:message> near the end. When I run the above file,
> xsltproc prints this:
>
>> xsltproc ../xsl/epub-chunk.xsl ../swarmwise.docbook >/dev/null
>> Chunk test: book -
>> Chunk test: bookinfo -
>> Chunk test: title -
>> Chunk test: subtitle -
>> Chunk test: preface - 0
>> Chunk test: highlights -
>> Chunk test: para -
>> Chunk test: para -
>> Chunk test: toc - 1
>> Chunk test: preface - 0
>> Chunk test: epigraph -
>> Chunk test: para -
>> Chunk test: para -
>> Chunk test: part -
>> Chunk test: title -
>> Chunk test: chapter -
>> Chunk test: title -
>
> And lots more lines like that with no return value. After that, it
> starts printing what looks like chunk IDs instead of 0/1 return values:
>
>> Note: namesp. add : added namespace before processing Swarmwise
>> Chunk test: -
>> Chunk test: preface - 0
>> Chunk test: preface - 0
>> Chunk test: preface - 0
>> Chunk test: book - book-idm139645148695504
>> Chunk test: book -
>> Chunk test: book -
>> Chunk test: book - book-idm139645148695504
>> Chunk test: preface - 0
>> Chunk test: preface - 0
>> Chunk test: preface - 0
>> Chunk test: book - book-idm139645148695504
>> Chunk test: book -
>> Chunk test: book -
>> Chunk test: book - book-idm139645148695504
>
> And after that, the chunk test output includes even pieces of text
> from the book itself instead of 0/1 return values - chapter titles,
> section titles and even entire paragraphs converted into plain text
> with no XML markup.
>
> Here's what xsltproc prints when I comment out the <xsl:message> block:
>
>> xsltproc ../xsl/epub-chunk.xsl ../swarmwise.docbook >/dev/null
>> Note: namesp. add : added namespace before processing Swarmwise
>> Error preface is not a chunk!
>> Writing OEBPS/ for preface(predmluva)
>> I/O error : Is a directory
>> I/O error : Is a directory
>> runtime error: file file:///usr/share/sgml/docbook/xsl-ns-stylesheets/xhtml/chunker.xsl line 172 element document
>> xsltDocumentElem: unable to save to OEBPS/
>> Error preface is not a chunk!
>> Writing OEBPS/ for preface
>> I/O error : Is a directory
>> I/O error : Is a directory
>> runtime error: file file:///usr/share/sgml/docbook/xsl-ns-stylesheets/xhtml/chunker.xsl line 172 element document
>> xsltDocumentElem: unable to save to OEBPS/
>> Writing OEBPS/ for section(hejno-je-otevrene)
>> I/O error : Is a directory
>> I/O error : Is a directory
>> runtime error: file file:///usr/share/sgml/docbook/xsl-ns-stylesheets/xhtml/chunker.xsl line 172 element document
>> xsltDocumentElem: unable to save to OEBPS/
>
> I'm using DocBook XSL NS Stylesheets 1.78.0 and xsltproc --version
> prints this:
>> Using libxml 20901, libxslt 10128 and libexslt 817
>> xsltproc was compiled against libxml 20901, libxslt 10128 and libexslt 817
>> libxslt 10128 was compiled against libxml 20901
>> libexslt 817 was compiled against libxml 20901
>
> I've also tried changing the imports according to xhtml/chunk.xsl (to
> generate normal chunked XHTML instead of Epub) but that just gave me
> slightly different error messages from xsltproc. When I import only
> epub3/chunk.xsl and comment out the custom "chunk" template, I get
> usable chunked Epub data with no error messages from xsltproc. What am
> I missing?
>
> Regards,
> Martin Doucha
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
docbook-apps-unsubscribe@lists.oasis-open.org> For additional commands, e-mail:
docbook-apps-help@lists.oasis-open.org>
>
>