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