Forum How do I...?

How do I add MathML to HTML?

ikaruga
The following code converts to PDF correctly BUT gives me warning messages:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
               "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
lang="en" xml:lang="en">
<body>
<m:math mode="display" xmlns="http://www.w3.org/1998/Math/MathML">
  <m:mrow>
    <m:mfrac>
      <m:mn>Tr(AW)</m:mn>
      <m:mn>Tr(W)</m:mn>
    </m:mfrac>
  </m:mrow>
</m:math>
</body>
</html>


As I said, the fraction displays correctly on the PDF but I get the following error messages:

 warning: Namespace prefix m is not defined
prince: test2.html:7: error: Tag m:math invalid


What am I doing wrong?
mikeday
You are using an "m:" prefix on the MathML elements, so the xmlns attribute needs to be xmlns:m in order to correctly bind that prefix to the MathML namespace URL. This will make it correct from an XML point of view, however, you will still get error messages when using the HTML parser for the time being. :)