section
Elements into sectX
ElementsYou need to transform every sectX
element into a
section
element.
This problem is solved through the following XSLT stylesheet:
The above stylesheet calculates the section level with the
ancestor
axis, because the amount of
elements is directly correlated with the level of the
corresponding section. With an attribute value template it is
inserted in the name
attribute.
There is one caveat: The stylesheet does not check if the
limit is reached. Currently (with version 5.1), DocBook supports
levels up to 5. If you nest your section
elements too
deep, you can end up with, let's say, sect8
which
is not allowed in DocBook. To avoid making
mistakes, it is better to check the level:
Amend the stylesheet when the section is too deeply nested (see above comment). You could avoid the section level (which is a bad idea) but it's better to rework the source document.
If you want, you can stop the transformation if the section
level is too high. Change the xsl:message
as
follows:
<xsl:message terminate="yes">...
Project@GitHub | Issue#8 |