XML technologies / DocBook / Customizing DocBook / Extending DocBook 5 / Extending DocBook with the CDList schema

(Excerpt from "DocBook-XML: Medienneutrales und plattformunabhängiges Publizieren" by Thomas Schraitle)

To integrate the CDList schema into DocBook 5, proceed as follows:

  1. Where should the CDList elements appear?
    First decide where the CDList elements should appear. The element cd:cd-collection is a candidate and fits well alongside tables, equations and similar structures. The definition pattern for this purpose is db.formal.blocks. For more definition patterns, see the table Naming conventions for DocBook 5.

  2. Creating the customization file
    Create your customization file and insert the following line:

<grammar xmlns="http://relaxng.org/ns/structure/1.0"><!-- Ihre Anpassungen --></grammar>

namespace cd = "http://www.example.org/ns/cd" 
default namespace db = "http://docbook.org/ns/docbook" 
namespace html = "http://www.w3.org/1999/xhtml" 
# Ihre Anpassungen

  1. Integrating the CDList schema
    Use externalRef/ external to reference your CD schema:

<define name="dbx.cdlist"> 
  <externalRef href="cd-list.rng"/> 
</define>

dbx.cdlist = 
  # Lädt die Datei "cd-list.rnc" in das Muster dbx.cdlist 
  external "cd.rnc"

  1. Loading the DocBook schema
    Integrate DocBook 5 and override the definition pattern db.formal.blocks:

<include href="docbook.rng"> 
    <define name="db.formal.blocks" combine="choice"> 
        <ref name="dbx.cdlist"/> 
    </define> 
    <define name="db._any"> 
        <element> 
            <anyName> 
                <except> 
                    <nsName ns="http://docbook.org/ns/docbook"/> 
                    <nsName ns="http://www.w3.org/1999/xhtml"/> 
                    <nsName ns="http://www.example.org/ns/cd"/> 
                </except> 
            </anyName> 
            <zeroOrMore> 
                <choice> 
                    <attribute> 
                        <anyName/> 
                    </attribute> 
                    <text/> 
                    <ref name="db._any"/> 
                </choice> 
            </zeroOrMore> 
        </element> 
    </define> 
</include>

include "docbook.rnc" { 
  db.formal.blocks |= dbx.cdlist 
  db._any = 
    element * - (db:* | html:* | cd:*) { 
      (attribute * { text } 
       | text 
       | db._any)* 
   } 
}

  1. Using the customization file
    Use the customization file instead of the original DocBook file (see Validating with a DocBook 5 customization file).

  

back to top