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.

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.