Subject: Re: [docbook-apps] Adding new element to the scheme
I know of two approaches to this problem.
In the first approach, in your customization layer process the requirement element into docbook table elements inside a variable, convert the variable's content to a node-set using the exlt:node-set() function, and then process the node-set with the standard DocBook stylesheets (see example below).
Preprocess your document into a temporary document with a
stylesheet that is an identity stylesheet except for templates
that process requirements into DocBook tables.Â The output is a
pure DocBook document, mixing your original DocBook elements
copied over with the generated DocBook tables.Â Then you can
process this temporary document with standard DocBook stylesheets.
The first approach has the advantage of being done in a single
XSLT process, because the table is held in memory and then
processed, while the second approach requires two XSLT
processes.ÂÂ The second approach has the advantage of
transparency, in that you can view the temporary output to see how
it is working, while an internal node-set is not visible.
Here is an example of the first approach that works for HTML processing, using a much simpler input element and link:
Â <requirement xml:id="myrequirement">
and the template that processes that (I'm assuming you are using DocBook 5):
Â <xsl:variable name="id" select="@xml:id"/>
Â <xsl:variable name="req">
Â <xsl:variable name="nodeset" select="exsl:node-set($req)"/>
Â <xsl:apply-templates select="$nodeset"/>
I used d:informaltable to avoid table numbering, because
requirement won't be counted as a table so the numbering sequence
won't be right (unless you fix the template that counts tables).Â
Since you didn't include a title, I assumed you meant
informaltable anyway.Â If you want these things numbered along
with your other tables, you will have to use the second approach.
Also, the nodeset approach won't work for FO output because the
informaltable in the nodeset is treated as a separate document,
and so the stylesheet will generate fo:root for the table within a
fo:page-sequence, which is invalid in the XSL-FO processor.Â
If you use the second, two-pass approach, a single first-pass
stylesheet can generate the temporary pure DocBook document for
either HTML or FO processing, so I would recommend that approach.Â
Let me know if you need more help with the identity stylesheet
Bob Stayton Sagehill Enterprises email@example.com
On 12/10/2018 5:44 AM, Ilan Finci wrote: