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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.14.252.56