Re: Validator support for MathML embedded in XHTML (moderately long)

Michael Bowen <fizzbowen@mindspring.com> wrote:

> >What problems did you encounter when you tried?
> 
> Several hundred, originally; with your help, it's down to about a dozen, 
> mostly having to do with the failure to recognize prefixed xmlns 
> attributes. I am using Mathplayer; the validator also doesn't like the 
> empty <object> element that Design Science wants us to use to invoke 
> MathPlayer. (MathPlayer doesn't run if the <object> and/or the <?IMPORT> 
> statement in the following line are commented out.)

XHTML+MathML document is an XML document so the following syntax is
wrong as a processing instruction:

    <?IMPORT namespace="m" implementation="#MathPlayer" />

It should look like this:

    <?IMPORT namespace="m" implementation="#MathPlayer"?>

Actually this error was hiding a bunch of errors thereafter - with
the former syntax, XML processors will consider the rest of the
document as PI.

> This was helpful, too, although IE 6 is still not quite smart enough not to 
> render the closing ]> at the end of the ATTLIST statement. So I get an odd 
> couple of characters at the top left corner of the document. Plus, I'm not 
> really validating to the "standard" DTD if I do this.

It seems your document is served as 'text/html'.  I know IE only works
with "HTML" + MathML served as 'text/html' at the moment, but I'm
afraid I would say serving an XHTML+MathML document as 'text/html'
is not the right thing to do.  IE works better with the internal DTD
subset when a resource is served as XML, but unfortunately MSXML
parser has problem with parsing modular DTD like XHTML+MathML DTD ...

> Interestingly, the MathML 2.0 recommendation 
> [http://www.w3.org/TR/MathML2/chapter7.html] makes the following 
> suggestion. It would be cool if the "standard" DTD made allowance for this 
> particular flavor of namespace prefixing.

It does.  See "A.3 Namespace prefix declarations" of MathML 2.0 REC [1]:

    As mentioned above, it is sometimes necessary, or convenient, to use
    the mechanisms described in [Modularization] which provide a namespace
    prefix on MathML element names. The DTD below is designed to allow
    this usage. If the parameter entity MATHML.prefixed is declared to be
    INCLUDE, using a declaration such as

        <!ENTITY % MATHML.prefixed "INCLUDE" >

    either in the local subset of the DOCTYPE declaration, or in the DTD
    file that is including the MathML DTD, then all MathML elements should
    be used with a prefix, for example <m:mrow>, <m:apply>, etc. The
    prefix defaults to m: but another prefix may be declared by declaring
    in addition the parameter entity MathML.prefix. For example,

        <!ENTITY % MATHML.prefix   "math" >

    would set the prefix for the MathML namespace to math:.

So if you want to use "m:" as a prefix, all you have to do is to
include the following parameter entity declaration in the internal
DTD subset of your document:

    <!ENTITY % MATHML.prefixed "INCLUDE" >

If you want to use the "Universal MathML stylesheet" and still
want to validate, you'll also have to include something like
the following in the internal DTD subset, too:

    <!ATTLIST html
        xmlns:pref CDATA #IMPLIED
        pref:renderer CDATA #IMPLIED>

This still doesn't allow you to declare "xmlns:m" on the html element
and such, but if you include the %MATHML.prefixed; parameter entity
declaration as shown above, the XHTML 1.1 plus MathML 2.0 DTD
automatically sets the following as part of the ATTLIST declaration
of the math element:

    xmlns:m  CDATA   #FIXED 'http://www.w3.org/1998/Math/MathML'

so strictly speaking it's not necessary to declare it on the html
elemnt.  Still if you want to declare it on the html element, you
have to include an appropriate ATTLIST declaration for the html
element like the one above in the internal DTD subset.  Unfortunately
the XHTML 1.1 plus MathML 2.0 DTD is not flexible enough to allow
such declaration automatically.  I'm working on an experimental
XHTML 1.1 plus MathML 2.0 plus SVG 1.1 DTD, and it does allow
such a declaration automatically, but I had to write a pretty hairy
conditional section to manage that.

BTW, it seems the validator has (known) problems with parsing
the entities in "mmlextra.ent".  "mmlextra.ent" includes a bunch
of character entities beyond U+FFFF, which nsgmls doesn't support
yet.

[1] http://www.w3.org/TR/MathML2/appendixa.html#parsing_namespaces

Regards,
-- 
Masayasu Ishikawa / mimasa@w3.org
W3C - World Wide Web Consortium

Received on Monday, 1 April 2002 03:32:45 UTC