Technologies XML / DocBook / Personnaliser DocBook / Étendre DocBook 5 / Extension de DocBook avec le schéma CDList

(Extrait de « DocBook-XML: Medienneutrales und plattformunabhängiges Publizieren » de Thomas Schraitle)

Pour intégrer le schéma CDList à DocBook 5, procédez comme suit :

  1. Où doivent apparaître les éléments CDList ?
    Décidez d’abord où doivent apparaître les éléments CDList. L’élément cd:cd-collection est un candidat adapté aux tableaux, équations et structures similaires. Le motif de définition correspondant est db.formal.blocks. Pour d’autres motifs de définition, voir le tableau Conventions de nommage de DocBook 5.

  2. Création du fichier de personnalisation
    Créez votre fichier de personnalisation et insérez la ligne suivante :

<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. Intégration du schéma CDList
    Utilisez externalRef/ external pour référencer votre schéma CD :

<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. Chargement du schéma DocBook
    Intégrez DocBook 5 et redéfinissez le motif de définition 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. Utilisation du fichier de personnalisation
    Utilisez le fichier de personnalisation à la place du fichier DocBook original (voir Valider avec un fichier de personnalisation DocBook 5).

  

haut de page