Making the MathML 2.0 Relax-NG schema work with libxml2

I’m writing this for Google.

If you’re trying to use libxml2 to validate MathML documents using the MathML 2.0 Relax-NG schema written by Yutaka Furubayashi, you’re probably getting ‘element ref: Relax-NG parser error : Found forbidden pattern list//ref’ messages for mml-datatypes.rng.

These errors are triggered when libxml2 finds a ref element inside a list. This appears to be one of the restrictions of Relax-NG, according to Eric van der Vlist’s RELAX NG book:

List patterns cannot have any of these descendants: list, ref (because after simplification, access to elements is done using references to named patterns), attribute, or text.

The problem is easy to fix by replacing all the ref elements with the actual definitions. This introduces some duplication, but it does work. If you don’t feel like doing this yourself, use this patch for mml2-relaxng20021208.zip.

By the way, the Jing validator has no problems with the original schema, and according to the Relax-NG schema for Relax-NG, it’s perfectly valid. I really can’t say for sure who’s at fault here. ;-)

Note: If you were looking at this page in a more modern browser like Mozilla Firefox or Safari, it would look and work better and faster.
Find out more…