Appendix B. A complete example of a DocBook article

  1 <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE article SYSTEM 
      "/afs/cern.ch/sw/XML/XMLBIN/share/www.oasis-open.org/docbook/xmldtd-4.2/docbookx.dtd"
    [
  5  <!ENTITY LaTeX "LaTeX">
     <!ENTITY TeX   "TeX">
     <!ENTITY PTeX  "PassiveTeX">
     <!ENTITY xmltex "<application>xmltex</application>">
    ]>
 10 <article>
    <articleinfo>
    <title>A Docbook document featuring a few formulae</title>
    <author><firstname>Michel</firstname> <surname>Goossens</surname>
    </author>
 15 <pubdate>Sunday, 17 March 2002</pubdate>
    <abstract>
    <para>
    This XML document is marked up according the the DocBook schema It
    shows a few elements of the DocBook vocabulary, as well as a couple of
 20 examples of mathematical expressions where we used MathML markup.
    </para>
    </abstract>
    </articleinfo>
    
 25 <sect1>
    <title>The Docbook model</title>
    <para>
    DocBook <citation><xref role="bib" linkend="bib.TDG99"
    endterm="bib.TDG99.abbrev"/></citation> proposes an XML model
 30 <citation><xref role="bib" linkend="bib.xml"
    endterm="bib.xml.abbrev"/></citation> for marking up technical
    documents.  It is particularly well-suited for software reference
    guides and computer equipment manuals.
    </para>
 35 
    <para>
    Docbook contains hundreds of elements to markup up clearly and
    explicitly the different components of an electronic document (book,
    article, reference guide, etc.), not only displaying its hierarchical
 40 structure but also indicating the semantical meaning of the various
    elements. The structure of the DTD is optimized to allow for
    customization, thus making it relatively straightforward to add or
    eliminate certain elements or attributes, to change the content model
    for certain structural groups, or to restrict the value that given
 45 attributes can take.
    </para>
    
    <para>
    Norman Walsh developed a set of XSL stylesheets to transform XML
 50 documents marked up using the DocBook DTD into HTML or XSL formatting
    objects. The latter can be interpreted by &PTeX; and &xmltex; to
    obtain PDF or PostScript output.
    </para>
    </sect1>
 55 
    <sect1>
    <title>MathML and mathematics</title>
    <para>
    MathML <citation><xref role="bib" linkend="bib.mathml"
 60 endterm="bib.mathml.abbrev"/></citation> is a W3C recommendation whose aim
    is to encode mathematical material for teaching and scientific
    communication at all levels.
    </para>
    
 65 <para>
    MathML consists of two parts: presentation (notation) et contents
    (meaning). MathML permits the conversion of mathematical information
    into various representations and output formats, including graphical
    displays, speech synthesizers, computer algebra programs, other
 70 mathematics typesetting languages, such as &TeX;, plain text,
    printers (PostScript), braille, etc.
    </para>
    
    <para>
 75 MathML has support for efficiently browsing long and complex
    mathematical expressoins and offers an extension mechanism. MathML
    code is human readable, easy to generate and process by software
    applications, and well suited for editing (even though MathML syntax
    might appear unnecessarily verbose and complex to the human reader).
 80 </para>
    
    <para>
    The W3C MathMl Working Group released the Second version of the the
    MathML Specification at the beginning of 2001. Two public initiatives
 85 that allow the display of MathML code direcly and that are under
    active development are W3C's <application>Amaya</application> and
    <application>Mozilla</application>. Commercial programs, such as IBM's
    <application>techexplorer</application> (a plugin for
    <application>Netscape</application> or Microsoft's
 90 <application>Internet Explorer</application>) or Design Science
    <application>Webeq</application> (using the Java applet technology)
    can display MathML formulae in present day browsers.  Several computer
    algebra programs, e.g., <application>Mathematica</application>, or
    editors using e.g., <application>mathtype</application>, offer a
 95 user-friendly interface to enter, produce or read mathematics material
    marked up in MathML.
    </para>
    </sect1>
    
100 <sect1>
    <title>Presentation markup</title>
    
    <para>
    The <emphasis>presentation</emphasis> part of MathML discribes the
105 spacial layout of the different elements of a mathematical expression.
    MathML presenation markup has about thirty elements, that form the
    basis of a mathematical syntax using classical visual layout model.
    Some fifty attributes provide precise control on the exact 
    positioning of the various components of the math expression.
110 </para>
    
    <para>
    The list of presentation elements follows.
    <variablelist>
115 <varlistentry>
    <term>Token elements</term>
    <listitem><para>
    <sgmltag class="element">mi</sgmltag>,<sgmltag class="element">mn</sgmltag>,
    <sgmltag class="element">mo</sgmltag>,<sgmltag class="element">mtext</sgmltag>,
120 <sgmltag class="element">mspace/</sgmltag>,<sgmltag class="element">ms</sgmltag>,
    <sgmltag class="element">mchar</sgmltag>,<sgmltag class="element">mglyph</sgmltag>
    </para></listitem>
    </varlistentry>
    <varlistentry>
125 <term>General layout schemata</term>
    <listitem><para>
    <sgmltag class="element">mrow</sgmltag>,<sgmltag class="element">mfrac</sgmltag>,
    <sgmltag class="element">msqrt</sgmltag>,<sgmltag class="element">mroot</sgmltag>,
    <sgmltag class="element">mstyle</sgmltag>,<sgmltag class="element">merror</sgmltag>,
130 <sgmltag class="element">mpadded</sgmltag>,<sgmltag class="element">mphantom</sgmltag>,
    <sgmltag class="element">mfenced</sgmltag>,<sgmltag class="element">menclose</sgmltag>
    </para></listitem>
    </varlistentry>
    <varlistentry>
135 <term>Script and limit schemata</term>
    <listitem><para>
    <sgmltag class="element">msub</sgmltag>,<sgmltag class="element">msup</sgmltag>,
    <sgmltag class="element">msubsup</sgmltag>,<sgmltag class="element">munder</sgmltag>,
    <sgmltag class="element">mover</sgmltag>,<sgmltag class="element">munderover</sgmltag>,
140 <sgmltag class="element">mmultiscripts</sgmltag>
    </para></listitem>
    </varlistentry>
    <varlistentry>
    <term>Tables and matrices</term>
145 <listitem><para>
    <sgmltag class="element">mtable</sgmltag>,<sgmltag class="element">mtr</sgmltag>,
    <sgmltag class="element">mtd</sgmltag>,<sgmltag class="element">maligngroup/</sgmltag>,
    <sgmltag class="element">malignmark/</sgmltag>
    </para></listitem>
150 </varlistentry>
    <varlistentry>
    <term>Enlivening expressions</term>
    <listitem><para>
    <sgmltag class="element">maction</sgmltag>
155 </para></listitem>
    </varlistentry>
    </variablelist>
    </para>
    
160 <sect2>
    <title>A MathML example</title>
    <para>
    A MathML formula can be typeset inline, as here
    <inlineequation>
165 <mml:math>
    <mml:mi>E</mml:mi><mml:mo>=</mml:mo><mml:mi>m</mml:mi><mml:msup><mml:mi>c</mml:mi>
    <mml:mn>2</mml:mn></mml:msup>
    </mml:math>
    </inlineequation>, Einstein's famous equation.
170 </para>
    
    <para>
    An mathematical equation can also be typeset in display mode using
    DocBook's <sgmltag class="element">informalequation</sgmltag> element,
175 as is shown in the following example containing a matrix:
    </para>
    
    <informalequation>
    <mml:math>
180 <mml:mrow>
      <mml:mi>A</mml:mi>
      <mml:mo>=</mml:mo>
      <mml:mfenced open="[" close="]">
        <mml:mtable><!-- table or matrix -->
185       <mml:mtr> <!-- row in a table  -->
             <mml:mtd><mml:mi>x</mml:mi></mml:mtd><!-- table -->
             <mml:mtd><mml:mi>y</mml:mi></mml:mtd><!-- entry -->
          </mml:mtr>
          <mml:mtr>
190          <mml:mtd><mml:mi>z</mml:mi></mml:mtd>
             <mml:mtd><mml:mi>w</mml:mi></mml:mtd>
          </mml:mtr>
        </mml:mtable>
      </mml:mfenced>
195 </mml:mrow>
    <mml:mtext>.</mml:mtext>
    </mml:math>
    </informalequation>
    
200 <para>
    Note the two attributes <sgmltag class="attribute">open</sgmltag> and
    <sgmltag class="attribute">close</sgmltag> on the <sgmltag
    class="element">mfenced</sgmltag> element to specify the style of the
    braces to be used. The MathML Specification <citation><xref role="bib"
205 linkend="bib.mathml" endterm="bib.mathml.abbrev"/></citation> contains
    a detailed list of all possible attributes associated to each
    presentation element.
    </para>
    </sect2>
210 </sect1>
    
    <sect1>
    <title>Content markup</title>
    
215 <para>
    The meaning of mathematical symbols (e.g., sums, products, integrals)
    exists independently of their rendering.  Moreover the presentation
    markup of an expression is not necessarily sufficient to evaluate its
    value and use it in calculations. Therefore, MathML defines
220 <emphasis>content</emphasis> markup to explicitly encode the
    underlying mathematical structure of an expressoin.
    </para>
    
    <para>
225 It is impossible to cover all of mathematics, so MathML proposes only
    a relatively small number of commonplace mathematical constructs,
    chosen carefully to be sufficient in a large number of
    applications. In addition, it provides a <emphasis>extension
    mechanism</emphasis> for associating semantics with new notational
230 constructs, thus allowing these to be encoded even when they are not
    in MathML content element base collection.
    </para>
    
    <para>
235 MathML's basic set of content elements was chosen to allow for simple
    coding of most of the formulas used in secondary education, through
    the first year of university. The subject areas targeted are
    arithmetic, algebra, logic and relations, calculus and vector
    calculus, set theory, sequences and series, elementary classical
240 functions, and statistics linear algebra.  Using this basic sets more
    complex constructs can be built.
    </para>
    
    <para>
245 The list of the content elements of MathML follows.
    <variablelist>
    <varlistentry>
    <term>token elements</term>
    <listitem><para>
250 <sgmltag class="element">cn</sgmltag>,<sgmltag class="element">ci</sgmltag>,
    <sgmltag class="element">csymbol</sgmltag> (MathML 2.0).
    </para></listitem>
    </varlistentry>
    <varlistentry>
255 <term>basic content elements</term>
    <listitem><para>
    <sgmltag class="element">apply</sgmltag>,<sgmltag class="element">reln (deprecated)</sgmltag>,
    <sgmltag class="element">fn (deprecated for externally defined 
    functions)</sgmltag>,
260 <sgmltag class="element">interval</sgmltag>,<sgmltag class="element">inverse</sgmltag>,
    <sgmltag class="element">sep</sgmltag>,<sgmltag class="element">condition</sgmltag>,
    <sgmltag class="element">declare</sgmltag>,<sgmltag class="element">lambda</sgmltag>,
    <sgmltag class="element">compose</sgmltag>,<sgmltag class="element">ident</sgmltag>.
    </para></listitem>
265 </varlistentry>
    <varlistentry>
    <term>arithmetic, algebra and logic</term>
    <listitem><para>
    <sgmltag class="element">quotient</sgmltag>,<sgmltag class="element">exp</sgmltag>,
270 <sgmltag class="element">factorial</sgmltag>,<sgmltag class="element">divide</sgmltag>,
    <sgmltag class="element">max and min</sgmltag>,<sgmltag class="element">minus</sgmltag>,
    <sgmltag class="element">plus</sgmltag>,<sgmltag class="element">power</sgmltag>,
    <sgmltag class="element">rem</sgmltag>,<sgmltag class="element">times</sgmltag>,
    <sgmltag class="element">root</sgmltag>,<sgmltag class="element">gcd</sgmltag>,
275 <sgmltag class="element">and</sgmltag>,<sgmltag class="element">or</sgmltag>,
    <sgmltag class="element">xor</sgmltag>,<sgmltag class="element">not</sgmltag>,
    <sgmltag class="element">implies</sgmltag>,<sgmltag class="element">forall</sgmltag>,
    <sgmltag class="element">exists</sgmltag>,<sgmltag class="element">abs</sgmltag>,
    <sgmltag class="element">conjugate</sgmltag>,<sgmltag class="element">arg</sgmltag> (MathML 2.0),
280 <sgmltag class="element">real</sgmltag> (MathML 2.0),<sgmltag class="element">imaginary</sgmltag> (MathML 2.0),
    <sgmltag class="element">lcm</sgmltag> (MathML 2.0).
    </para></listitem>
    </varlistentry>
    <varlistentry>
285 <term>relations</term>
    <listitem><para>
    <sgmltag class="element">eq</sgmltag>,<sgmltag class="element">neq</sgmltag>,
    <sgmltag class="element">gt</sgmltag>,<sgmltag class="element">lt</sgmltag>,
    <sgmltag class="element">geq</sgmltag>,<sgmltag class="element">leq</sgmltag>,
290 <sgmltag class="element">equivalent</sgmltag> (MathML 2.0),<sgmltag class="element">approx</sgmltag> (MathML 2.0).
    </para></listitem>
    </varlistentry>
    <varlistentry>
    <term>calculus and vector calculus</term>
295 <listitem><para>
    <sgmltag class="element">int</sgmltag>,<sgmltag class="element">diff</sgmltag>,
    <sgmltag class="element">partialdiff</sgmltag>,<sgmltag class="element">lowlimit</sgmltag>,
    <sgmltag class="element">uplimit</sgmltag>,<sgmltag class="element">bvar</sgmltag>,
    <sgmltag class="element">degree</sgmltag>,<sgmltag class="element">divergence</sgmltag> (MathML 2.0),
300 <sgmltag class="element">grad</sgmltag> (MathML 2.0),<sgmltag class="element">curl</sgmltag> (MathML 2.0),
    <sgmltag class="element">laplacian</sgmltag> (MathML 2.0).
    </para></listitem>
    </varlistentry>
    <varlistentry>
305 <term>theory of sets</term>
    <listitem><para>
    <sgmltag class="element">set</sgmltag>,<sgmltag class="element">list</sgmltag>,
    <sgmltag class="element">union</sgmltag>,<sgmltag class="element">intersect</sgmltag>,
    <sgmltag class="element">in</sgmltag>,<sgmltag class="element">notin</sgmltag>,
310 <sgmltag class="element">subset</sgmltag>,<sgmltag class="element">prsubset</sgmltag>,
    <sgmltag class="element">notsubset</sgmltag>,<sgmltag class="element">notprsubset</sgmltag>,
    <sgmltag class="element">setdiff</sgmltag>,<sgmltag class="element">card</sgmltag> (MathML 2.0).
    </para></listitem>
    </varlistentry>
315 <varlistentry>
    <term>sequences and series</term>
    <listitem><para>
    <sgmltag class="element">sum</sgmltag>,<sgmltag class="element">product</sgmltag>,
    <sgmltag class="element">limit</sgmltag>,<sgmltag class="element">tendsto</sgmltag>.
320 </para></listitem>
    </varlistentry>
    <varlistentry>
    <term>elementary classical function</term>
    <listitem><para>
325 <sgmltag class="element">exp</sgmltag>,<sgmltag class="element">ln</sgmltag>,
    <sgmltag class="element">log</sgmltag>,<sgmltag class="element">sin</sgmltag>,
    <sgmltag class="element">cos</sgmltag>,<sgmltag class="element">tan</sgmltag>,
    <sgmltag class="element">sec</sgmltag>,<sgmltag class="element">csc</sgmltag>,
    <sgmltag class="element">cot</sgmltag>,<sgmltag class="element">sinh</sgmltag>,
330 <sgmltag class="element">cosh</sgmltag>,<sgmltag class="element">tanh</sgmltag>,
    <sgmltag class="element">sech</sgmltag>,<sgmltag class="element">csch</sgmltag>,
    <sgmltag class="element">coth</sgmltag>,<sgmltag class="element">arcsin</sgmltag>,
    <sgmltag class="element">arccos</sgmltag>,<sgmltag class="element">arctan</sgmltag>,
    <sgmltag class="element">arccosh</sgmltag>,<sgmltag class="element">arccot</sgmltag>,
335 <sgmltag class="element">arccoth</sgmltag>,<sgmltag class="element">arccsc</sgmltag>,
    <sgmltag class="element">arccsch</sgmltag>,<sgmltag class="element">arcsec</sgmltag>,
    <sgmltag class="element">arcsech</sgmltag>,<sgmltag class="element">arcsinh</sgmltag>,
    <sgmltag class="element">arctanh</sgmltag>.
    </para></listitem>
340 </varlistentry>
    <varlistentry>
    <term>statistics</term>
    <listitem><para>
    <sgmltag class="element">mean</sgmltag>,<sgmltag class="element">sdev</sgmltag>,
345 <sgmltag class="element">variance</sgmltag>,<sgmltag class="element">median</sgmltag>,
    <sgmltag class="element">mode</sgmltag>,<sgmltag class="element">moment</sgmltag>.
    </para></listitem>
    </varlistentry>
    <varlistentry>
350 <term>linear algebra</term>
    <listitem><para>
    <sgmltag class="element">vector</sgmltag>,<sgmltag class="element">matrix</sgmltag>,
    <sgmltag class="element">matrixrow</sgmltag>,<sgmltag class="element">determinant</sgmltag>,
    <sgmltag class="element">transpose</sgmltag>,<sgmltag class="element">selector</sgmltag>,
355 <sgmltag class="element">vectorproduct</sgmltag> (MathML 2.0),<sgmltag class="element">scalarproduct</sgmltag> (MathML 2.0),
    <sgmltag class="element">outerproduct</sgmltag> (MathML 2.0).
    </para></listitem>
    </varlistentry>
    <varlistentry>
360 <term>semantic mapping element</term>
    <listitem><para>
    <sgmltag class="element">annotation</sgmltag>,<sgmltag class="element">semantics</sgmltag>,
    <sgmltag class="element">annotation-xml</sgmltag>.
    </para></listitem>
365 </varlistentry>
    <varlistentry>
    <term>constant and symbol element (all MathML 2.0)</term>
    <listitem><para>
    <sgmltag class="element">integers</sgmltag>,<sgmltag class="element">reals</sgmltag>,
370 <sgmltag class="element">rationals</sgmltag>,<sgmltag class="element">naturalnumbers</sgmltag>,
    <sgmltag class="element">complexes</sgmltag>,<sgmltag class="element">primes</sgmltag>,
    <sgmltag class="element">exponentiale</sgmltag>,<sgmltag class="element">imaginaryi</sgmltag>,
    <sgmltag class="element">notanumber</sgmltag>,<sgmltag class="element">true</sgmltag>,
    <sgmltag class="element">false</sgmltag>,<sgmltag class="element">emptyset</sgmltag>,
375 <sgmltag class="element">pi</sgmltag>,<sgmltag class="element">eulergamma</sgmltag>,
    <sgmltag class="element">infinity</sgmltag>.
    </para></listitem>
    </varlistentry>
    </variablelist>
380 </para>
    
    <sect2>
    <title>An example with content markup</title>
    
385 <para>
    The matrix example given in the preceding section in its presentation markup
    form if recoded here using content markup.
    <programlisting>&lt;reln>
      &lt;eq/>
390   &lt;ci>A&lt;/ci>
      &lt;matrix>
        &lt;matrixrow>
          &lt;ci>x&lt;/ci>&lt;ci>y&lt;/ci>
        &lt;/matrixrow>
395     &lt;matrixrow>
          &lt;ci>z&lt;/ci>&lt;ci>w&lt;/ci>
        &lt;/matrixrow>
      &lt;/matrix>
    &lt;/reln>
400 </programlisting>
    </para>
    </sect2>
    </sect1>
    
405 <bibliography>
    <title>Bibliographic references</title>
    <biblioentry id="bib.xml">
    <abbrev id="bib.xml.abbrev">XML98</abbrev>
    <authorgroup>
410 <author><othername>World Wide Web Consortium</othername></author>
    <editor><firstname>Tim</firstname><surname>Bray</surname></editor>
    <editor><firstname>Jean</firstname><surname>Paoli</surname></editor>
    <editor><firstname>Michael</firstname><surname>Sperberg-McQueen</surname></editor>
    </authorgroup>
415 <title>
    <ulink url="http://www.w3.org/TR/REC-xml/">Extensible Markup Language
    (XML) 1.0</ulink></title>
    <bibliomisc>
    See also the <ulink url="http://www.xml.com/axml/axml.html">annotated
420 version of the XML specification</ulink>.</bibliomisc>
    </biblioentry>
    <biblioentry id="bib.TDG99">
    <abbrev id="bib.TDG99.abbrev">TDG1999</abbrev>
    <authorgroup>
425 <author><firstname>Norman</firstname><surname>Walsh</surname></author>
    <author><firstname>Leonard</firstname><surname>Muellner</surname></author>
    </authorgroup>
    <title>Docbook. The Definitive Guide.</title>
    <publisher>
430 <publishername>O'Reilly &amp; Associates, Inc.</publishername>
    </publisher>
    <copyright><year>1999</year></copyright>
    <isbn>1-56592-580-7</isbn>
    <releaseinfo><ulink
435 url= "http://www.oreilly.com/catalog/docbook/index.html">Oreilly's
    catalog entry</ulink>.
    </releaseinfo>
    <bibliomisc>
    You can also consult the <ulink url=
440 "http://www.oasis-open.org/docbook/documentation/reference/html/docbook.html">
    online version of the DocBook reference guide</ulink> and download the
    <ulink url="http://sourceforge.net/projects/docbook/">Docbook DTD and XSL
    stylesheets</ulink>.</bibliomisc>
    </biblioentry>
445 <biblioentry id="bib.mathml">
    <abbrev id="bib.mathml.abbrev">MATHML2</abbrev>
    <authorgroup>
    <author><othername>World Wide Web Consortium</othername></author>
    <editor><firstname>David</firstname><surname>Carlisle</surname></editor>
450 <editor><firstname>Patrick</firstname><surname>Ion</surname></editor>
    <editor><firstname>Robert</firstname><surname>Miner</surname></editor>
    <editor><firstname>Nico</firstname><surname>Poppelier</surname></editor>
    </authorgroup>
    
455 <title><ulink url="http://www.w3.org/TR/MathML2/">Mathematical
    Markup Language (MathML) Version 2.0</ulink>
    </title>
    </biblioentry>
    </bibliography>
460 </article>

The result of transforming the DocBook source of this appendix into PDF (with docbook2pdf, see Example 1.6 in Section 1.7) is shown in Figure B.1.

Figure B.1. DocBook example with MathML translated into PDF

DocBook example with MathML (page 1)DocBook example with MathML (page 2)
DocBook example with MathML (page 3)DocBook example with MathML (page 4)

We can also transform the DocBook source into HTML with docbook2html, as explained in Section 1.5. On the one hand, we can convert it into a single output file (as in Example 1.2), and the result is shown in Figure B.2 as displayed with the Mozilla browser. This figure corresponds to the beginning of the output file. On the other hand, Figure B.3 shows one of the chunks generated when running docbook2html with the chunk option (see Example 1.4 for an explanation). For large files it is more efficient to use chunking to allow handling of reasonably-sezed output files that have to be served over the Web.

Figure B.2. DocBook example with MathML translated into HTML and viewed with Mozilla (one file)

DocBook example with MathML translatex into HTML
    and viewed with the Mozilla browser (one large HTML file).

Figure B.3. DocBook example with MathML translated into HTML and viewed with Mozilla (chunked file)

DocBook example with MathML translatex into HTML
    and viewed with the Mozilla browser (chunked at section level).