\documenttype[mathml-altheim]{html}
% Locate gellmu.el as "http://www.albany.edu/~hammond/gellmu/private/gellmu.el"
% Use: "emacs -batch -l gellmu.el -f gellmu-xml whatever.glm" to make
% "whatever.xml". Then view "whatever.xml" with MathML-enabled Mozilla.
% The "mathml-altheim" \documenttype option sets it up for Murray Altheim's
% XHTML 1.1 plus MathML 2.0 unified document type definition.
%
% This type of "package building" is run-time inefficient, but it is good for
% test work.
\macro{\ }{ }
\newcommand{\glmu}{http://www.albany.edu/~hammond/gellmu}
\newcommand{\glmv}{http://math.albany.edu:8000/~hammond/gellmu}
\newcommand{\glma}[2][]{\a[href="\glmu/#1"]{#2}}
\newcommand{\glmb}[2][]{\a[href="\glmv/#1"]{#2}}
\newcommand{\href}[2][http://www.w3.org/]{\a[href="#1"]{#2}}
\newcommand{\w3u}{http://www.w3.org}
\newcommand{\w3a}[2][]{\a[href="\w3u/#1"]{#2}}
\newcommand{\mns}{xmlns="http://www.w3.org/1998/Math/MathML"}
\newcommand{\irmath}[1]{\math[\mns mode="inline"]{\mrow{#1}}}
\newcommand{\drmath}[1]{\math[\mns class="display" mode="display"]{\mrow{#1}}}
\newcommand{\plus}{\mo{+}}
\newcommand{\minus}{\mo{-}}
\newcommand{\neg}[1]{\mrow{\minus#1}}
\newcommand{\mul}{\mo{ }}
\newcommand{\eq}{\mo{=}}
\newcommand{\eqn}[2]{\mrow{#1}\mo{=}\mrow{#2}}
\newcommand{\pm}{\mo{±}}
\newcommand{\pi}{π}
\newcommand{\bal}[1]{\mfenced{\mrow{#1}}}
\newcommand{\balsb}[1]{\mfenced[open="[" close="]"%
]{\mrow{#1}}}
\newcommand{\balbr}[1]{\mfenced[open="\{" close="\}"%
]{\mrow{#1}}}
\newcommand{\balinv}[1]{\mfenced[open=" " close=" "%
]{\mrow{#1}}}
\newcommand{\lbalbr}[1]{\mfenced[open="\{" close=""%
]{\mrow{#1}}}
\newcommand{\norm}[1]{\mfenced[open="||" close="||"%
]{\mrow{#1}}}
\newcommand{\gexp}[2][\mi{e}]{\msup{\mrow{#1}\mrow{#2}}}
\newcommand{\sgexp}[2][\mi{e}]{\msup{#1#2}}
\newcommand{\infty}{\mi{∞}}
\newcommand{\dlog}[1]{\sfrac{\mr{\mi{d#1}}}{\mi{#1}}}
\newcommand{\ifrac}[2]{\mr{#1\mo{/}#2}}
\newcommand{\frac}[2]{\mfrac{\mrow{#1}\mrow{#2}}}
\newcommand{\sfrac}[2]{\mfrac{#1#2}}
\newcommand{\sqrt}[1]{\msqrt{\mrow{#1}}}
\newcommand{\int}[3]{\msubsup{\mo{∫}\mrow{#1}#2}\mrow{#3}}
\newcommand{\sum}[3]{\msubsup{\mo{∑}\mrow{#1}#2}\mrow{\mspace;#3}}
\newcommand{\prod}[3]{\msubsup{\mo{∏}\mrow{#1}#2}\mrow{#3}}
\newcommand{\mxtwo}[4]{%
\mtable{\mtr{\mtd{#1}\mtd{#2}}\mtr{\mtd{#3}\mtd{#4}}}%
}
% This defn needs to appear after any use in others.
\newcommand{\mr}[1]{\mrow{#1}}
\begin{head}
\link[rel="stylesheet" type="text/css" href="gmmld.css"];
\title{GELLMU and MathML}
\end{head}
\begin{body}
\h1{Using GELLMU to Write XHTML with MathML}
\h2[class="display"]{William F. Hammond}
\p[class="display"]{\b{30 May 2001}}
\p[class="display"]{Copyright © 2001 William F. Hammond}
\p[class="display"]{Email: \kbd{hammond@math.albany.edu}}
\h2{About this document}
\p{
This document is an example of what it is describing. The intention
is that the user should be able to view \glma{gmml.glm}{its source}
while also viewing its rendering, and that should be instructive. The
\glma{gmml.xml}{plain text} representation of the intermediate XML
document (perhaps also available with a browser's "view-source" function)
may also instructive.
}
\p{
There are at least two widely distributed browsers that render XHTML
with MathML natively.}
\begin{ol}
\li{The \href{World Wide Web} Consortium's
\href{http://www.w3.org/Amaya/}{Amaya}.}
\li{The MathML branch of the
\href{http://www.mozilla.org/projects/mathml/}{Mozilla} browser.}
\end{ol}
\p{
It is also reported that \href{http://www.microsoft.com/}{Microsoft's}
Internet Explorer \em{with a plugin} from
\href{http://www.dessci.com/}{Design Science} can be used to
render \glma{gmml.html}{the text/html serving} of this document.
The 0.8.1 version of Mozilla appears to render MathML elements only
from the \glmb{gmml.xml}{the text/xml serving} of this document.
Amaya appears to handle both versions the same way.
}
\p{This document has passed validation with Murray Altheim's document type
definition for
\href{http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd}{XHTML 1.1
plus MathML 2.0}.
}
\h2{How to use GELLMU for XHTML with MathML}
\h3{Differences between the XML and classical versions of HTML}
\p{
Most of what is required is explained in
\glma{ghtml.html}{Using GELLMU to Write HTML}. Somewhat more can
be understood by examining the \glma{ghtml.glm}{source markup} for
that document as well as the \glma{gmml.glm}{source for this} document.
}
\p{The most important things to note about the difference
between classical HTML and the version of HTML formalized under XML:}
\begin{dl}
\dt{Case sensitivity}
\dd{All element and attribute names in the XML version of HTML are
case sensitive and lower case. All entity names are case-sensitive,
and some entity names are mixed case.}
\dt{No omitted tags}
\dd{Every open tag must be matched by an close tag. In GELLMU this
means that the markup \kbd{"\\foo"} is never acceptable except sometimes
when it is used for invoking a newcommand.}
\dt{XML declared-empty tag syntax}
\dd{
\p{Whereas in classical HTML a tag such as \em{br} is correctly marked
up with \kbd{"
"}, for the XML version of HTML it must be marked up
with \kbd{"
"} or, more generally, any amount of whitespace can be
inserted between \kbd{"
"}. Since the markup
\kbd{"
"} is, in fact, wrong for classical HTML, it is recommended
that \kbd{"
"} be used for the XML version of HTML in order to
avoid unnecessary incompatibility with old browsing tools.}
\p{With GELLMU one simply marks up "\kbd{\\br;}". If the syntactic
translator is invoked with the Emacs Lisp function \em{gellmu-xhtml},
the empty tag form preferred for XHTML is created; for the whitespace free form
use \em{gellmu-xml}. Note that \em{gellmu-html} is not correct for
any XML document type.}
}
\end{dl}
\h3{Document Type Handling}
\p{
An XHTML plus MathML document should begin with the markup
\kbd{\\documenttype[mathml-altheim]\{html\}}. It is, after all, an
HTML document. For XHTML, the XML version of HTML, the HTML element
names, including that of the root element, must all be marked up with
lower case characters. XML element names generally are case sensitive
but not necessarily lower case. The MathML element names used here
are all lower case, but that might not be true forever, and some of
the MathML entity names, which are also case sensitive, have mixed
case.}
\p{
The \em{documenttype} option string \kbd{"mathml-altheim"} points to a
list of document type information known to the
\glma{gellmu.el}{syntactic translator} indicating that the document
type is an XML document type with the formal public identifier for
Altheim's merged XHTML 1.1 plus MathML 2.0 document type
definition and also that the content encoding is UTF-8 and that the
root tag should have an attribute list with the single "xmlns"
attribute having the value \kbd{"\w3u/1999/xhtml"}. It also
provides the string \kbd{"mathml.dtd"} as system identifier for the
document type definition. This value is special for the development
version of Mozilla, which appears for now not to fetch any network
served system identifier. (Currently I have 0.8.1, build id
2001032722.) For validation purposes one may bypass the incomplete
copy distributed with Mozilla by using that system identifier as a
catalog front.}
\p{
The string \kbd{"mathml-altheim"} is more formally a key to the Emacs
lisp variable "gellmu-doctype-info". New keys may be added by a user
either interactively in Emacs once \glma{gellmu.el}{\kbd{gellmu.el}}
is loaded (as a library) or else by adding a few lines of code such as
\glma{private/dotemacs-clip}{dotemacs-clip} to the Emacs configuration
file, which often has the filesystem name \kbd{".emacs".}}
\h3{Macro Substitution Meta-Commands}
\p{
The term meta-command refers to a command that does not correspond
to an XML element. Meta-commands usually receive substantial
intelligent processing from the GELLMU syntactic translator, whereas
ordinary commands simply correspond to XML elements and receive only
syntactic transliteration from the syntactic translator.
The name \em{documenttype} is that of a meta-command.}
\p{ For basic GELLMU there are three types of meta-commands providing
classical macro substitution: (1) \em{macro}, (2) \em{newcommand}, and
(3) \em{Macro}. (Regular GELLMU, which provides a more comprehensive
layer of LaTeX markup emulation, also has a macro substitution meta-command
called \em{mathsym} for declaring mathematical symbols entirely apart from
standard XML namespaces with optional provision for conveying semantic
information such as semantic types to XML processors.)}
\p{
Each of \em{macro} and \em{Macro} takes two arguments delimited by
braces. The first argument is called its name -- though it can be any
string except one with unbalanced braces or the character \kbd{"\\"}
except as the first character. The second argument is called its
value string; it may not contain unbalanced braces.}
\p{
The syntactic translator makes three forward scans of the document
first expanding each \em{macro} from the point forward of its
location, then expanding each \em{newcommand} forward from its
location, and finally expanding each \em{Macro} forward from its
location.}
\p{
\em{newcommand} provides substitution with arguments, more or less as
in LaTeX except that it is macro substitution rather than new element
creation, and there may be any number of arguments. If the name
argument is followed by an option, then that is the number of
arguments that the new command will take. A second option is the
default value, as in LaTeX2E, of the first argument. In the value
field one references the first argument, as with LaTeX, using
\kbd{\#1}, the 12\sup{th} argument using \kbd{\#12}, etc. Each
argument may have arbitrary content except unbalanced braces.
The command name of a \em{newcommand} should consist only of word
characters or numbers.}
\p{
None of the three macro substitution meta-commands may be invoked
before it is defined except for the case where it appears in the value
string of another. One must be mindful that each is expanded forward
from the point of its location. If one of these is used in the
value string of another after it is defined, then the expansion of
the first in that value string will take place in that value string,
but if it is used in the value string of another before it is defined,
then the expansion will take place forward of the location of the
other at each of the expansion sites of the other. (This may or may
not be of consequence.)}
\h3{Restrictions for avoiding infinite loops.}
\begin{ol}
\li{
None of the macro substitution meta commands may reference its own
name in its value string.}
\li{
If a meta-command taking arguments is used in the value string of
another meta-command taking arguments, then the definition of the
latter must precede that of the former.}
\end{ol}
\h2{Examples}
\begin{p}
This is an XHTML document with MathML markup prepared using the basic
layer of GELLMU and the XML namespaces regime for extending the basic
tagset of XHTML.
\end{p}
\p{The following relation is sometimes called the \em{parallelogram law}.}
\drmath{
\eqn{
\gexp{\norm{\mi{a}}}{\mn{2}}
\plus
\gexp{\norm{\mi{b}}}{\mn{2}}
}{
\frac{\mn{1}}{\mn{2}}
\mul
\balbr{
\gexp{\norm{\mi{a}\plus \mi{b}}}{\mn{2}}
\plus
\gexp{\norm{\mi{a}\minus\mi{b}}}{\mn{2}}
}
}
}
\p{Balancers should be stretched when appropriate. Here the simple
fraction
\irmath{\ifrac{\mn{1}}{\mn{2}}}
is multiplied with a complex fraction.}
\drmath{
\frac{\mn{1}}{\mn{2}}
\mul
\balbr{
\frac{
\frac{\mi{a}}{\mi{b}}
}{
\frac{\mi{c}}{\mi{d}}
}
}
}
\p{This is MathML markup of the formula for the roots of the quadratic
polynomial
\irmath{\mtext{\ }
\mi{a}\mul\gexp{\mi{x}}{\mn{2}}\plus\mi{b}\mul\mi{x}\plus\mi{c}} .}
\drmath{
\mi{x}
\eq
\frac{
\neg{\mi{b}}
\pm
\gexp{
\bal{\gexp{\mi{b}}{\mn{2}}\minus\mn{4}\mul\mi{a}\mul\mi{c}}
}{
\mn{1}\mo{/}\mn{2}
}
}{
\mn{2}\mul\mi{a}
}
}
\p{This is MathML markup for a 2 × 2 matrix.}
\drmath{
\mi{A}\eq\balsb{
\mxtwo{\mi{a}}{\mi{b}}{\mi{c}}{\mi{d}}
}}
\p{Taylor's Theorem:}
\drmath{
\eqn{
\mo{f}\bal{\mi{x}}
}{
\sum{
\eqn{\mi{j}}{\mn{0}}
}{
\infty
}{
\balinv{
\frac{\gexp{\mo{f}}{\bal{\mi{j}}}\bal{\mi{0}}}{\mi{j}\mo{!}}
\mul
\gexp{\mi{x}}{\mi{j}}
}
}
}
}
\p{This is a form of the Weierstrass infinite product expansion of the
gamma function.}
\drmath{
\mrow{
\int{\mn{0}}{\infty}{
\gexp{\mi{t}}{\mi{x}} \mul \gexp{\mi{-t}} \mul
\dlog{t}
}
}
\eq
\balinv{
\frac{\mn{1}}{\mi{x}} \mul
\prod{\mrow{\mi{k}\mo{=}\mn{1}}}{\infty}{
\mrow{
\frac{
\gexp{\bal{\mn{1}\plus\frac{\mn{1}}{\mi{k}}}}{\mi{x}}
}{
\bal{\mn{1}\plus\frac{\mi{x}}{\mi{k}}}
}
}
}
}
}
\p{Dirac's δ-function, which is actually a distribution in the
sense of L. Schwartz rather than a function, is characterized by the
property that for every \irmath{\msup{\mi{C}\infty}}
function \irmath{\mi{f}} with compact support one has:}
\drmath{
\eqn{
\int{\neg{\infty}}{\infty}{\mi{f}\mi{δ}}
}{
\mo{f}\bal{\mn{0}}
}
\mtext{\ .}
}
\p{In particular, when \irmath{\mi{f}} is the characteristic function
\irmath{\msub{\mi{I}\mi{S}}} of a set \irmath{\mi{S}}:}
\drmath{
\eqn{
\int{\mi{S}}{\mi{}}{\mi{δ}}
}{
\lbalbr{
\mtable{
\mtr{
\mtd{\mn{1}}
\mtd{\mtext{\ if\ }\mi{S}\mtext{\ contains\ }\mn{0}\mtext{.}}
}
\mtr{
\mtd{\mn{0}}
\mtd{\mtext{\ otherwise.}}
}
}
}
}
}
\end{body}