Search code examples
xmlxsltdocbook

Changing the root element in a DocBook transformation


Good morning,

I'm playing around with DocBook and basically I love it :-) The first way to really give structure to documents and to also enforce it.

In this context I'm using a custom Schema and xslt Transformation to model some of the content of my document. This all work really great.

Now I want to also change the root element of the docbook file. At the moment it is a <book> but I want it to be a <specificationX>. I added the <specificationX> element to my rnc Schema as follows:

db.specificationX =
   element specificationX {
      db.common.attributes,
      db.specY  
   }
start |= db.specificationX

The validation of my document works fine but as soon as I get to the XSLT transformation I'm getting an error:

ERROR: Document root element for FO output must be one of the following elements: appendix article bibliography book chapter ....

Obviously I have to advise my stylesheet about the changed root element as well. However, I have no idea, how to do this and could not find any information on this.

Can anybody here give me a hint or point me into the correct direction?

Thanks in advance! Norbert


Solution

  • There are different versions of DocBook and different versions of different stylesheets, you have not explained in any way which version you use but see https://github.com/docbook/xslt10-stylesheets/blob/master/xsl/fo/docbook.xsl#L122 for instance which sets up

    <xsl:variable name="root.elements" select="' appendix article bibliography book chapter colophon dedication glossary index part preface qandaset refentry reference sect1 section set setindex '"/>
    

    which presumably can be changed or overridden from an importing stylesheet to include your customized element name.