如何在 DocBook 5.0 中正确包含常量字符串?

How to properly include a constant string in DocBook 5.0?

我正在开发的软件有使用 DTD 在 DocBook 4.2 中编写的文档,我想迁移到 5.0 并放弃 DTD。大部分内容都已迁移,但最后剩下的是版本宏。我曾经有一个名为 version.ent:

的文件(由 Makefile 生成)
<!ENTITY __VERSION__ "1.2.3-git">

然后在我希望包含软件版本的每个文件中引用一次该文件:

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

有了这些,就可以做这样的事情:

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

如何在不使用 DTD 的情况下在 DocBook 5.0 中实现这种机制?

经过一番挖掘,我发现解决方案是内部 DTD 子集。我错误地认为不应该完全使用 DTD,但这是不正确的。

此页面解释得很好:http://www.sagehill.net/docbookxsl/Db5Entities.html。相关语录:

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.

另外:

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.