Other Modifications

Changing the Contents of the role Attribute

The role attribute, found on almost all of the elements in DocBook, is a text attribute that can be used to subclass an element. In some applications, it may be useful to modify the definition of role so that authors must choose one of a specific set of possible values.

In Example 5-14, the role attribute on the procedure element is constrained to the value required or optional.

Example 5-14. Changing role on procedure

namespace db = "http://docbook.org/ns/docbook"

include "docbook.rnc" {
   db.procedure.role.attribute = attribute role { "required" | "optional" }
}

Adding a Value to an Enumerated Attribute

Example 5-15 adds the value large to the db.spacing.enumeration pattern. Any attribute that is defined using db.spacing.enumeration will now have large as a legal value. Note that while it is easy to add a value to an enumeration, to remove a value from an enumeration you need to redefine the entire enumeration, minus the values you don’t need.

Example 5-15. Adding a value to an enumeration

namespace db = "http://docbook.org/ns/docbook"
default namespace = "http://docbook.org/ns/docbook"

include "docbook.rnc"

# add a value to an enumeration
db.spacing.enumeration |= "large"

Get DocBook 5: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.