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

Adding Attributes

The simplest way to add an attribute to a single element is to add it to the attlist pattern for that element. Example 5-13 adds the optional attributes born and died to the attribute list for author. The db.author.attlist pattern is redefined to interleave the two new optional attributes with the existing attributes on the list.

Example 5-13. Adding born and died attributes

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

include "docbook.rnc"

db.author.attlist &=                             1
  attribute born { db.date.contentmodel }?           2
  & attribute died { db.date.contentmodel }?
1

&= interleaves the two new optional attributes with the existing attributes on the list.

2

db.date.contentmodel is a pattern used for any attribute or element that represents a date.

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