2

While writing a large manual in DocBook 5 (which uses an XSD, not DTD), I need to mention the version name in many places. For example, the name of distribution zip includes the version name. That version name changes constantly, so I 'd like to use a variable for that.

How do I do variable substitution in DocBook 5 (which uses an XSD, not DTD)?

Geoffrey De Smet
  • 26,223
  • 11
  • 73
  • 120

1 Answers1

2

An XML entity is a kind of macro or substitutable variable, so I suggest that you use one or more of those. Entities can be declared and referenced in any XML document, even if a DTD is not used for validation.

Declaration of the version entity (an internal entity):

<?xml version="1.0"?>
<!DOCTYPE book [
<!ENTITY version "Version X">
]>
<book xmlns="http://docbook.org/ns/docbook" version="5.0">
 ...
</book>

Reference to the version entity:

<book xmlns="http://docbook.org/ns/docbook" version="5.0">
 ...
 <para>The current version is &version;</para>
</book>

When the document is parsed, the parser replaces all occurrences of &version; with Version X.

There are more details and suggestions here: http://www.sagehill.net/docbookxsl/Db5Entities.html.

mzjn
  • 48,958
  • 13
  • 128
  • 248