The convoluted construction for the declaration of the MathML namespace in the MathML 2.0 DTD defeats DTDParse.
DTDParse gets confused at 'xmlns:%MATHML.prefix;' during the expansion of:
with the result firstly that '%MATHML.prefix;' is treated as the attribute value declaration and secondly that DTDParse misses the end of the attribute list declaration and treats the following declaration as part of the attribute list.
The eventual output is:
Attlist mml:mathError: %mathml-charent.module; undeclared.
One solution is to expand parameter entity references in entity values as part of parsing the entity declaration in parse_entity(). (I will leave it to a reader more familiar with the code to work out how to pass $expand to parse_entity() to control whether or not to expand entity references.)
Also, the debug output when parsing attribute lists is confusing since there's no labelling of the output of $values and $type. It doesn't help to have them look the same when DTDParse is reporting one as the other.