# Math 300: MathML, XML, and XHTML (back to Math 300 notes)

MathML, the Mathematical Markup Language, is a standard developed by W3C for typesetting mathematics on the World Wide Web. It has long been possible to use HTML to typeset some very simple mathematical expressions, such as

a x2 + b x + c = 0

but it was never possible to type the quadratic formula for the roots of that equation until the advent of MathML. However, at long last, we can now do so. If $a$ is not zero, then one of the roots of the equation above is given by the formula $- b 2 + b 2 - 4 a c 12 2 a .$ Note that we can equivalently write $- b 2 + b 2 - 4 a c 2a$

This was formerly done through the magic of XML and XHTML, so we should gain a little bit of understanding of those languages. XML stands for Extensible Markup Language. It tries to answer the need for ever increasing formatting on Web pages, and to combine that with a need to manage data on the Web, flavoring all of that with the W3C's constant battle against procedural markup. Thus, XML has the following properties, among others.

• It has no predefined tags
• It requires stricter syntax than HTML
• All formatting of XML is handled externally through DTDs and style specifications

Anyone can write an XML file, making up tags as she goes along. Nothing is predefined, so you may choose any tag names you like. About the only thing that is required is that for every starting <tag> there must be an ending </tag>. Thus, XML documents generally have the following properties.

• The markup in XML documents is all structural - it describes the content of the document, not the formatting.
• A single XML document might be formatting in a variety of ways, depending on the external formatting specifications for its tags.

DTD stands for Document Type Definition. It is here that XML tags begin to acquire meaning. It is here that the XML element address, for example, could be defined to be composed of the other elements street, city, postal-code. Here one can specify whether a given subelement is required, whether it is a database key, or whether it is simple string information.

DTDs are already considered to be too limiting to be used indefinitely. The W3C is already working on generalized forms for these that ultimately will replace DTDs. Stay tuned.

Formatting in XML documents is handled through XSL, the XML Stylesheet Language. It is here that one may translate XML into other languages such as HTML, or one could reorganize the XML to extract information and form new XML documents, e.g. to give a table of contents for the XML. XSL is like CSS, except it does more: it supports transforming the document entirely before display. For example, one might use XSL not only to format a document, but to format it using HTML and styles.

Building an XML document directly from scratch, creating a DTD to describe the data relations, and formatting it for display by creating an XSL sheet would be a tremendous task - too great for simply making one little web page. Fortunately, the W3C provides numerous resources for us to tap into. One of the most useful is XHTML. As you might have guessed, this stands for Extensible HyperText Markup Language. It represents an effort to make HTML nothing more than a subset of XML. XHTML 1.0 constitutes a DTD for xml documents that can interpret XML tags as HTML tags. XHTML looks different from HTML in a number of ways.

• Since XHTML is XML, then all tags that can be closed, must be closed. It is no longer acceptable to have a paragraph start tag followed by another.
• The few tags that have no closing tag in HTML (such as the IMG tag) must end with a slash, e.g. <img src="mypic.jpg" />.
• Tags must be nested properly.
• All tag names are given in lower case.
• The headers in XHTML documents look much more complicated than those for HTML.

Nowadays we do not require XML or XHTML to create MathML - the markup language is built-in to HTML5. Nonetheless, it adheres to its XML roots syntactically.