MathML files may now be validated at the W3C Validator.
In order to validate a single MathML expression one may use the MathML DTD as specified in Appendix A of the MathML specification.
For example:
<!DOCTYPE math PUBLIC "-//W3C//DTD MathML 2.0//EN" "http://www.w3.org/TR/MathML2/dtd/mathml2.dtd"> <math> <mn> 1 </mn> <mo> + </mo> <mn> 2 </mn> </math>
To validate a whole series of MathML expressions it is easier to make an XHTML family document, also as described in appendix A:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN" "http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>MathML's Hello Square</title> </head> <body> <p> This is a perfect square:</p> <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> <msup> <mfenced> <mrow> <mi>a</mi> <mo>+</mo> <mi>b</mi> </mrow> </mfenced> <mn>2</mn> </msup> </mrow> </math> <math> .... </math> <math> .... </math> </body> </html>
These files may be submited to the W3C validator at http://validator.w3.org/.
However, at the time of writing the validator will only recognise them as MathML (and XML) if they are sent with the non standard mime type "mathml".
In the case of the XHTML document, a simple solution is to use the .html extension on your test file, but use the XHTML meta element to force the content type to be MathML.
The W3C validator does correctly raise an error with the following well formed document, as xxx is not a defined element:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN" "http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>MathML's Hello Square</title> <meta http-equiv ="content-type" content="mathml" /> </head> <body> <p> This is a perfect square:</p> <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow><xxx/> <msup> <mfenced> <mrow> <mi>a</mi> <mo>+</mo> <mi>b</mi> </mrow> </mfenced> <mn>2</mn> </msup> </mrow> </math> </body> </html>