docbook-apps

  • 1.  Re: [docbook-apps] endnotes section in ePub

    Posted 07-11-2011 20:11
    Well, that looks like it will be a problem. Here is the import sequence (highest
    priority first):

    1. YourCustomization.xsl,
    which xsl:imports:
    2. epub/docbook.xsl,
    which xsl:includes chunk-code.xsl (element chunking templates)
    and which xsl:imports:
    3. xhtml-1_1/docbook.xsl (element formatting templates) and xhtml-1_1/chunk-common.xsl
    (utility chunking templates)

    Note that epub/docbook.xsl *includes* chunk-code.xsl, which is not import but instead
    puts the included templates at the same import level as those in epub/docbook.xsl
    (level 2).

    Let's say you put a template like this in YourCustomization.xsl:

    <xsl:template match="d:appendix[@role = 'endnotes']">
    [format the content of the special appendix]

    When your stylesheet processes the appendix element, the best match is the highest
    import template which is your custom one at level 1, and so it will proceed with
    creating the formatted list of footnote entries. But that's wrong, because there is
    no chunked HTML wrapper for that formatted content to be placed into. I suspect that
    formatted content would be sent to standard output instead of to any file.

    What you would like to do is have the XSLT processor select the chunking template from
    Level 2, and apply formats from Level 1. There is no way for you to write such a
    template for your customization layer.

    I can see that the stock epub stylesheet should be restructured to better support
    customization. With the current version, I think you would have to do this:

    a. Create a new stylesheet module to customize the formatting of content, perhaps
    named CustomEpubFormat.xsl.

    b. In CustomEpubFormat.xsl, add xsl:import href="path-to/xhtml-1_1/docbook.xsl", and
    add any templates to customize element formatting, such as the one for endnotes.

    c. Copy the epub/docbook.xsl file to a new filename like CustomEpubChunk.xsl.

    d. In CustomEpubChunk.xsl, change the first xsl:import to:
    <xsl:import href="CustomEpubFormat.xsl"/> (instead of ../xhtml-1_1/docbook.xsl)
    And leave the rest of it alone.

    Now process your document with CustomEpubChunk.xsl. When the appendix is encountered,
    the matching templates with the highest import precedence is the stock appendix
    chunking template (in chunk-code.xsl which is xsl:included in CustomEpubChunk.xsl).
    So that template is applied and will create the chunk wrapper for the appendix, and
    then apply xsl:apply-imports. When it does apply imports, the processor will pass
    over any templates at Level 1 and look in Levels 2 and below. So it looks in
    CustomEpubFormat.xsl and finds your custom template for formatting the special
    appendix. For all other elements that are not customized, it will fall further in the
    import sequence to ../xhtml-1_1/docbook.xsl to handle the formatting. That should
    work.

    The problem with this customization is that epub/docbook.xsl has almost 1700 lines of
    code which must be copied to CustomEpubChunk.xsl. I don't like having to copy so much
    code for no purpose. When I rewrite this, I'll move everything but the imports and
    includes to a separate stylesheet module that can be included. That would make it
    easier to insert a customization into the import sequence without having to copy over
    all those templates in epub/docbook.xsl

    Bob Stayton
    Sagehill Enterprises
    bobs@sagehill.net





  • 2.  RE: [docbook-apps] endnotes section in ePub

    Posted 07-18-2011 19:27
    Hi all,

    Thanks, Bob, for the instructions, and thanks Robert for asking good questions of clarification.

    The priority issue makes perfect sense to me, and I've built out a series of stylesheets as described (I already had a custom layer importing epub/docbook.xsl, so I just pasted epub/docbook.xsl into that and imported the CustomEpubFormat.xsl instead of docbook.xsl). Everything seems to process fine without me having tackled the issue of how to gather those footnotes and dump them into this appendix I have created.

    I'm a little stumped, though, on the more mundane task of figuring out how output my footnotes into this appendix. Can anyone provide a little advice or a resource that might help me get started with filling out the [format the content of the special appendix] portion of this question?

    Again, the directions in Bob's book for customizing print footnotes to endnotes doesn't seem to translate into the way the XHTML-1_1 style sheets are structured.

    Any help would be greatly appreciated.

    Jason