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:
Downloading the MathML RELAX NG schema
Download the MathML RELAX NG schema.Creating the customization file
Create a customization file (for exampledbmathml.rncordbmathml.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)*
}
}Using the customization file
Save the customization filedbmathml.rncordbmathml.rngin 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.mmlMore information about the MathML specification.
Copyright © 2009 Millin Verlag
You may print the online version for your private use.
Otherwise, this chapter from "DocBook-XML: Medienneutrales und plattformunabhängiges Publizieren" is subject to the same provisions as the printed edition: the work, including all its parts, is protected by copyright. All rights are reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
Millin Verlag, Siebengebirgsring 36, 53797 Lohmar, info(at)millin.de
back to top