XML technologies / DocBook / Customizing DocBook / DocBook 5 structure / Examples of commonly needed patterns

(Excerpt from "DocBook-XML: Media-neutral and platform-independent publishing" by Thomas Schraitle)

Important element patterns include:

db._any

Any element from any namespace (except DocBook and XHTML)

db._text

Contains text and the patterns db.ubiq.inlines, db._phrase and db.replaceable.

db._title

Contains titles such as title, titleabbrev and subtitle, all optional.

db._title.req

Like db._title, but a title is required.

db._title.only

Only two optional titles, title and titleabbrev are available

db._title.onlyreq

Like db._title.only, but title is required.

db.all.blocks

Contains all block elements from different categories: db.nopara.blocks, db.para.blocks, db.extension.blocks and db.annotation.

db.all.inlines

Contains all inline elements from different categories: db.ubiq.inlines, db.general.inlines, db.domain.inlines and db.extension.inlines.

Important attribute patterns include:

db.effectivity.attributes

Contains references to the attributes audience, condition, conformance, os, revision, security, userlevel, vendor and wordsize

db.href.attributes

Contains all attributes of XLink

db.common.attributes

Contains db.effectivity.attribute and the attributes annotations, dir, remap, revisionflag, version, xml:base, xml:id (optional), xml:lang and xreflabel.

db.common.idreq.attributes

Like db.common.attributes, but the attribute xml:id must be specified.

The example of book explains the individual components in more detail.

Example: Structure of book in DocBook 5

RNC

div {
  db.book.status.attribute = db.status.attribute
  db.book.role.attribute = attribute role { text }
  db.book.attlist =
    db.book.role.attribute?
    & db.common.attributes
    & db.common.linking.attributes
    & db.label.attribute?
    & db.book.status.attribute?
db.book.info = db._info.title.req
db.book =
  ## A book 
  # Ausgeblendetes Schematronmuster
  element book {
    db.book.attlist,
    db.book.info,
    (db.navigation.components | db.components | db.divisions)+
  }
}

RNG

<div>
    <define name="db.book.status.attribute">
        <ref name="db.status.attribute"/>
    </define>
    <define name="db.book.role.attribute"> 
        <attribute name="role"/>
    </define>
    <define name="db.book.attlist">
        <interleave>
            <optional>
                <ref name="db.book.role.attribute"/>
            </optional>
            <ref name="db.common.attributes"/>
            <ref name="db.common.linking.attributes"/>
            <optional>
                <ref name="db.label.attribute"/>
            </optional>
            <optional>
                <ref name="db.book.status.attribute"/>
            </optional>
        </interleave>
    </define>
    <define name="db.book.info">
        <ref name="db._info.title.req"/>
    </define>
    <define name="db.book">
        <element name="book">
            <a:documentation>A book</a:documentation>
            <!-- Ausgeblendetes Schematronmuster -->
            <ref name="db.book.attlist"/>
            <ref name="db.book.info"/>
            <oneOrMore>
                <choice>
                    <ref name="db.navigation.components"/>
                    <ref name="db.components"/>
                    <ref name="db.divisions"/>
                </choice>
            </oneOrMore>
        </element>
    </define>
</div>

RNC and RNG line 2: Reference to the attribute declaration of status.
RNC line 3 and RNG line 5: Attribute declaration of role.
RNC line 4 and RNG line 8: Attribute list of a book.
RNC line 10 and RNG line 23: Content model of info inside a book.
RNC line 12 and RNG line 28: Element documentation.
RNC line 13 and RNG line 29: Schematron pattern, explained in Schematron in more detail.
RNC line 14 and RNG line 27: Element declaration of book with its content model.
RNC line 17 and RNG line 32: References to other components of a book.

  

back to top