O'Reilly logo

DocBook 5: The Definitive Guide by Richard L. Hamilton, Norman Walsh

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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"

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required