Technologies XML / DocBook / Personnaliser DocBook / Étendre DocBook 5 / Extension de DocBook avec MathML

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

MathML signifie Mathematical Markup Language et sert à baliser des formules mathématiques. DocBook 5 fournit un point d’entrée pour MathML au moyen du motif db._any.mml. Redéfinissez ce motif avec les éléments MathML pour disposer du balisage des formules dans equation et informalequation.

Pour ajouter MathML à DocBook 5, procédez comme suit :

  1. Téléchargement du schéma RELAX NG de MathML
    Téléchargez le schéma RELAX NG de MathML.

  2. Création du fichier de personnalisation
    Créez un fichier de personnalisation (par exemple dbmathml.rnc ou dbmathml.rng):

    Exemple : Fichier de personnalisation de DocBook avec MathML

<?xml version="1.0" encoding="UTF-8"?> 
<grammar xmlns="http://relaxng.org/ns/structure/1.0"> 
    <include href="docbook.rng"> 
        <define name="db._any.mml"> 
            <externalRef href="mathml2.rng"/> 
        </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.w3.org/1998/Math/MathML"/> 
                    </except> 
                </anyName> 
                <zeroOrMore> 
                    <choice> 
                        <attribute> 
                            <anyName/> 
                        </attribute> 
                        <text/> 
                        <ref name="db._any"/> 
                    </choice> 
                </zeroOrMore> 
            </element> 
        </define> 
    </include> 
</grammar>

namespace db = "http://docbook.org/ns/docbook" 
namespace mml = "http://www.w3.org/1998/Math/MathML" 
namespace html = "http://www.w3.org/1999/xhtml" 
include "docbook.rnc" { 
  db._any.mml = external "mathml2.rnc" 
  db._any = 
    element * - (db:* | html:* | mml:*) { 
      (attribute * { text } 
       | text 
       | db._any)* 
   } 
}

  1. Utilisation du fichier de personnalisation
    Enregistrez le fichier de personnalisation dbmathml.rnc ou dbmathml.rng dans le même répertoire que vos fichiers XML. Validez votre document avec l’un des fichiers de personnalisation ci-dessus ; voir Valider avec un fichier de personnalisation DocBook 5.

Pour autoriser aussi MathML dans inlineequation insérez à l’intérieur de include le code suivant :

Exemple : Code supplémentaire pour inlineequation

<define name="db.inlineequation.content" combine="choice">
    <ref name="db._any.mml"/>
</define> 

# Kombination durch Auswahl
db.inlineequation.content |= db._any.mml

En savoir plus sur spécification MathML.

  

haut de page