D. Integrating MathML with document types other than DocBook 5, DITA Topic and XHTML 5

Warning

Normal users are not supposed to do this. The intended audience for this appendix is consultants and local gurus.

What follows is a description of what has been done to integrate MathML with DocBook 5. Integrating MathML with other document types should be very similar.

  1. File mathml_addon_install_dir/docbook5/mathml_support.incl contains these additional configuration elements:

    <configuration xmlns="http://www.xmlmind.com/xmleditor/schema/configuration"
      xmlns:cfg="http://www.xmlmind.com/xmleditor/schema/configuration"
      xmlns:db="http://docbook.org/ns/docbook"
      xmlns:mml="http://www.w3.org/1998/Math/MathML">
    
      <validate namespace="http://www.w3.org/1998/Math/MathML">1
        <relaxng location="../common_rng/mathml2.rng" />
      </validate>
    
      <include location="../common/mathml.incl" />2
      ...
      Extend the DocBook menu and toolbar here
      ...
      <elementTemplate name="mathml">3
        <equation xmlns="http://docbook.org/ns/docbook">
          <title></title>
          <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML"
                    display="block">
            <mml:mi></mml:mi>
          </mml:math>
        </equation>
      </elementTemplate>
    </configuration>

    1

    Dynamically merge the RELAX NG schema of MathML presentation markup (mathml2.rng) with the stock RELAX NG schema of DocBook 5 (docbook.rng). See below.

    2

    Include the MathML configuration.

    3

    Among other extensions, specify one or more templates for elements embedding MathML elements.

    How the MathML schema is dynamically merged with the DocBook 5 schema

    1. The RELAX NG schema of DocBook 5 is declared in the stock DocBook 5 configuration XXE_install_dir/addon/config/docbook5/docbook5.xxe.

      <relaxng location="rng/V5.0/docbook.rng" />
    2. The validate configuration element allows to merge one or more auxiliary DTDs or schemas to the main DTD or schema.

      <validate namespace="http://www.w3.org/1998/Math/MathML">
        <relaxng location="../common_rng/mathml2.rng" />
      </validate>

    You'll find:

    • the W3C XML Schema for MathML (both presentation and content markup) in mathml_addon_install_dir/standalone/xsd/mathml2.xsd,

    • the RELAX NG schema for MathML (presentation markup only) in mathml_addon_install_dir/common_rng/mathml2.rng,

    • the RELAX NG schema Compact Syntax for MathML (presentation markup only) in mathml_addon_install_dir/common/pane/mathml2.rnc.

      Both mathml2.rng and mathml2.rnc have been translated from the MathML DTD using trang.

    However nothing forces you to merge schemas of the same kind. More information in XMLmind XML Editor - Configuration and Deployment.

  2. The above file is referenced in the stock DocBook 5 configuration (XXE_install_dir/addon/config/docbook5/docbook5.xxe) as follows:

    <!-- Do not report an error if the "MathML support" add-on 
         has not been installed. -->
    <include location="---1mathml-config:docbook5/mathml_support.incl2" />

    1

    The "---" prefix before an URL instructs XXE to silently skip the inclusion when the URL cannot be successfully resolved.

    2

    URL mathml-config:docbook5/mathml_support.incl resolves to mathml_addon_install_dir/docbook5/mathml_support.incl because XML catalog mathml_addon_install_dir/mathml_catalog.xml contains the following rule:

    <rewriteURI uriStartString="mathml-config:" rewritePrefix="." />
  3. File mathml_addon_install_dir/docbook5/mathml_support.imp contains the following additional CSS rules:

    @import url(../common/mathml.css);1
    
    @namespace db5 "http://docbook.org/ns/docbook";
    
    db5|imagedata:contains-element(mml|math),2
    db5|inlineequation > mml|math,
    db5|informalequation > mml|math,
    db5|equation > mml|math {
        content: "";
    }

    1

    Import the CSS stylesheet for MathML elements.

    2

    Suppress the generated content normally used to style the imagedata, inlineequation, etc, DocBook 5 elements.

  4. The above file is referenced in the stock DocBook 5 CSS stylesheet (XXE_install_dir/addon/config/docbook5/css/docbook5.css) as follows:

    /* Do not report an error if the "MathML support" add-on 
       has not been installed. */
    @import url(---mathml-config:docbook5/mathml_support.imp);