Overview: Mathematical Markup Language (MathML) Version 2.0
Previous: 7 The MathML Interface
Next: A Parsing MathML
8 Document Object Model for MathML
8.1 Introduction
8.1.1 hasFeature String
8.1.2 MathML DOM Extensions
This document extends the Core API of the DOM Level 2 to describe objects and methods specific to MathML elements in documents. The functionality needed to manipulate basic hierarchical document structures, elements, and attributes will be found in the core document; functionality that depends on the specific elements defined in MathML will be found in this document.
The actual DOM specification appears in Appendix D [Document Object Model for MathML].
The goals of the MathML-specific DOM API are:
This document includes the following specializations for MathML:
MathMLElement
interface derived from the core
interface Element
. MathMLElement specifies the operations and
queries that can be made on any MathML element. Methods on
MathMLElement
include those for the retrieval and modification
of attributes that apply to all MathML elements.
MathMLElement
to encode
syntactical restrictions imposed by MathML.
MathMLElement
representing all
MathML elements with attributes extending beyond those specified in the
MathMLElement
interface. For all such attributes, the derived
interface for the element contains explicit methods for setting and getting
the values.
Node
and
Element
interfaces must clearly remain available, it is felt
that in many cases they may be misleading. Thus, for instance, the
MathMLFractionElement
interface provides for access to
numerator
and denominator
attributes; a call to
setDenominator(newNode)
is less ambiguous from a calling
application's perspective than a call to Node::replaceNode(newNode,
Node::childNodes().item(2))
.
MathML specifies rules that are invisible to generic XML processors and validators. The fact that MathML DOM objects are required to respect these rules, and to throw exceptions when those rules are violated, is an important reason for providing a MathML-specific DOM extension.
There are basically two kinds of additional MathML grammar and syntax rules. One kind involves placing additional criteria on attribute values. For example, it is not possible in pure XML to require that an attribute value be a positive integer. The second kind of rule specifies more detailed restrictions on the child elements (for example on ordering) than are given in the DTD. For example, it is not possible in XML to specify that the first child be interpreted one way, and the second in another. The MathML DOM objects are required to provide this interpretation.
MathML ignores whitespace occurring outside token elements. Non-whitespace characters are not allowed there. Whitespace occurring within the content of token elements is `trimmed' from the ends (i.e. all whitespace at the beginning and end of the content is removed), and `collapsed' internally (i.e. each sequence of 1 or more whitespace characters is replaced with one blank character). The MathML DOM elements perform this whitespace trimming as necessary. In MathML, as in XML, `whitespace' means blanks, tabs, newlines, or carriage returns, i.e. characters with hexadecimal Unicode codes U+0020, U+0009, U+000a, or U+000d, respectively.
Support for the MathML Document Object Model may be queried by calling the
DOMImplementation::hasFeature
method with the test string "org.w3c.dom.mathml".
It is expected that a future version of the MathML DOM may deal with issues which are not resolved here. Some of these are described here.
It is likely that a need will become obvious for MathML-specific specializations of interfaces belonging to the Traversal and Range Modules of the Document Object Model Level 2. The order of traversal of bound variables, conditions, and declarations - or whether they should be omitted from a given traversal altogether - offers an example of a potential utility for such specializations. However, it would be premature to specify any such interfaces at this time. Implementation experience will be necessary in order to discover the appropriate interfaces which should be specified.
Overview: Mathematical Markup Language (MathML) Version 2.0
Previous: 7 The MathML Interface
Next: A Parsing MathML