IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose,
or store or copy the information in any medium. Thank you.
Both ways worked as a charm (with the mentioned problem of using the first method for FO).
Ended up using the identity stylesheet method.
From: Bob Stayton <email@example.com>
Date: Tuesday, 11 December 2018 at 7:40
To: "firstname.lastname@example.org" <email@example.com>
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:
<link linkend="myrequirement">Link to Requirement</link>
and the template that processes that (I'm assuming you are using DocBook 5):
<xsl:variable name="id" select="@xml:id"/>
<xsl:variable name="nodeset" select="exsl:node-set($req)"/>
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
On 12/10/2018 5:44 AM, Ilan Finci wrote:
Iâm new to docbook and XSLT, and tried to find the answer among the different books/websites and failed, so looking up for your help (pointers to the right place will be good as well).
Iâm trying to add a new element to my docbook, that will describe a requirement for example:
<description>We need to be able to save a snapshot of requirements per product version</description>
In my outputs, I want to format each such requirement as a table. Writing same table as docbook table directly, I would have something like:
<colspec colnum="1" colname="1" colwidth="*" />
<colspec colnum="2" colname="3" colwidth="*" />
<colspec colnum="3" colname="3" colwidth="*" />
<colspec colnum="4" colname="4" colwidth="*" />
<spanspec spanname="desc" namest="1" nameend="3"/>
<entry spanname="desc"><para> We need to be able to save a snapshot of requirements per product version </para></entry>
I tried to add this to stylesheet, but I cannot write âdocbookâ table there, and I have to do it per output format (HTML â use the tr & td flags, FO for PDF and other print formatsâ)
- Is there a way to do the conversion of the new ârequirementâ into docbook code, which will automatically be formatted as HTML or FO later, base on the
xsltproc parameters I give?
- Is there a way to add reference based on the requirement ID (so I can link to it later)?
Thanks in advance
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose
the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.