Reusing assembly modules with unique IDs - using <output> and <transform>?
Peter Desjardins <[email protected]> Tue, 4 Jan 2022 22:18:11 -0500
| Newsgroups | gmane.text.docbook.apps |
|---|---|
| Message-ID | <CAMmOXbbNQgMZgST4w+KnvXyAMUEGVozkaY9CCCvqnhezF_NWUA@mail.gmail.com> |
It looks like including an <output> element in a <module> to specify an
XSLT <transform> might be a clean way to transform xml:id values to make
them unique. I see that <transform> elements are not handled in the current
implementation
<https://github.com/docbook/xslt10-stylesheets/blob/master/xsl/assembly/assemble.xsl#L746>
of DocBook assembly processing.
Am I understanding <output> and <transform> in a way that's consistent with
their design <https://tdg.docbook.org/tdg/5.1/ch06.html#transformations>?
I'm asking because I'm considering a proposed implementation of
<transform>. If there's a better way to make reused module IDs unique, I'd
prefer to use that. But maybe implementing transform this way would be
generally helpful?
More context:
I am trying to construct a DocBook 5.1 book with a reused module. The
content in the module is required in more than one place in the book and I
don't want to rely on cross-references to a single copy of the content.
That would disrupt the reader's context in this large document.
Reusing a module in the same structure works just fine until the referenced
topic content includes an xml:id value. Then the resulting DocBook book is
invalid because of duplicate IDs.
I see that Bob Stayton's excellent DocBook XSL: The Complete Guide covers
making xml:id values unique in modular content using XInclude
<http://www.sagehill.net/docbookxsl/DuplicateIDs.html#ModifyIdValues>. I'm
using pure DocBook <assembly> for my books and I don't want to add
XIncludes to my processing chain.
Here's an example of the DocBook <assembly> I want to use:
<?xml version="1.0" encoding="UTF-8"?>
<assembly version="5.1">
<resources xml:id="myResources">
...
</resources>
<structure renderas="book" xml:id="myGuide">
<module renderas="chapter" resourceref="myTopLevelSectionIntro">
<module renderas="section" resourceref="myTopicOne" />
<module renderas="section" resourceref="myTopicOne">
<merge><title>A repeated topic</title></merge>
<!-- The output element transforms the resourceref topic as
defined by the named transform element. -->
<output transform="makeModuleIdValuesUnique"/>
</module>
</module>
</structure>
<transforms>
<!-- The XSLT in this transform copies all nodes, and also prepends
a unique value to each of the xml:id values it copies. -->
<transform href="../utilities/make-module-id-values-unique.xsl"
name="makeModuleIdValuesUnique"/>
</transforms>
</assembly>
Thanks for your help!
Peter