XML technologies / DocBook / Customizing DocBook / Extending DocBook 5 / Extending DocBook with MathML

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

MathML stands for Mathematical Markup Language and is used to mark up mathematical formulas. DocBook 5 provides an entry point for MathML through the pattern db._any.mml. Override this pattern with MathML elements to make formula markup available within equation and informalequation.

To add MathML to DocBook 5, proceed as follows:

  1. Downloading the MathML RELAX NG schema
    Download the MathML RELAX NG schema.

  2. Creating the customization file
    Create a customization file (for example dbmathml.rnc or dbmathml.rng):

    Example: Customization file for DocBook with 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. Using the customization file
    Save the customization file dbmathml.rnc or dbmathml.rng in the same directory as your XML files. Validate your document using one of the customization files above; see Validating with a DocBook 5 customization file.

To also allow MathML in inlineequation insert inside the include the following code:

Example: Additional code for inlineequation

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

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

More information about the MathML specification.

  

back to top