macrosconstantsdocbookdocbook-5

How to properly include a constant string in DocBook 5.0?


The software I'm developing has documentation written in DocBook 4.2 with DTD and I'd like to migrate to 5.0 and drop DTD. Most of the content is migrated, but one last remaining thing is version macro. I used to have a file (generated by Makefile) called version.ent:

<!ENTITY __VERSION__ "1.2.3-git">

This file was then referenced once in every file I wanted to have the software version included:

<!ENTITY % version SYSTEM "version.ent">
%version;
]>

With those in place, it was possible to do things like this:

Welcome to the User's guide of foo version &__VERSION__.

How such mechanism should be implemented in DocBook 5.0 without using DTD?


Solution

  • After a bit of digging, I found the solution to be internal DTD subset. I mistakenly assumed that DTD is not supposed to be used altogether, but it was incorrect.

    This page explains it well: http://www.sagehill.net/docbookxsl/Db5Entities.html. Relevant quotes:

    When you switch from DTDs to RelaxNG (or to W3C XML Schema, for that matter), you lose the ability to define XML entities in the schema.

    Also:

    You can still use entities in DocBook 5, but you cannot declare them in the RelaxNG schema. Instead, you must reference your entity declarations in the DOCTYPE declaration of each document that needs them.