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 Elements

Adding a new inline or block element is generally a straightforward matter of creating a pattern for the new element and using |= to add it to the right pattern, as we did in Example 5-1. But if your new element is more intimately related to the existing structure of the document, it may require more surgery.

Example 5-12 extends DocBook by adding a sect6 element.

Example 5-12. Adding a sect6 element

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

include "docbook.rnc" {
   db.sect5.sections = (db.sect6+, db.simplesect*) | db.simplesect+
}

db.sect6.sections = db.simplesect+

db.sect6.status.attribute = db.status.attribute
db.sect6.role.attribute = attribute role { text }
db.sect6.attlist =
   db.sect6.role.attribute?
 & db.common.attributes
 & db.common.linking.attributes
 & db.label.attribute?
 & db.sect6.status.attribute?

db.sect6.info = db._info.title.req

db.sect6 =
   element sect6 {
      db.sect6.attlist,
      db.sect6.info,
      ((db.all.blocks+, db.sect6.sections?)
       | db.sect6.sections),
      db.navigation.components*
   }

Here we’ve redefined sect5 to include sect6 and provided a pattern for sect6.

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