XML technologies / MathML / Presentation markup / Other elements / Displaying error messages

(Excerpt from "The MathML Handbook" by Pavi Sandhu)

The merror element displays its contents as an error message. It is intended as a way of displaying syntax errors encountered when an application is generating MathML from some other form of input. Each application can choose its own style for displaying the contents of the merror element so they are easy to distinguish from the surrounding text (for example, in a different color or with a different background).

The suggested use of the merror element is for an application to replace the erroneous part of the input with an merror element that contains a description of the error. The application then continues processing the surrounding input as normally as possible. This way, the error message appears at the location where the erroneous input would have appeared, making it easier to identify the cause of the error.

The merror element can contain any arbitrary MathML expression. Typically the text of the error message is enclosed in an mtext element. If the erroneous input contains fragments that are correctly formatted, then these can be processed normally and included in the contents of the error message.

For example, suppose a user includes the MathML element mssub instead of the MathML element msub because of a typing error, as shown in the following markup:

<mssub>
  <mi>&ExponentialE;</mi>
  <mrow>
    <mi>&ImaginaryI;</mi>
    <mi>&InvisibleTimes;</mi>
    <mi>&pi;</mi>
  </mrow>
</mssub>

When this markup is processed by an application that checks for MathML syntax, an error message like the following might be produced:

<merror>
  <mtext>Unrecognized element at line 17:mssub;arguments were:</mtext>
  <mi>&ExponentialE;</mi>
  <mtext>and</mtext>
  <mrow>
    <mi>&ImaginaryI;</mi>
    <mi>&InvisibleTimes;</mi>
    <mi>&pi;</mi>
  </mrow>
</merror>

   

 

 

 

 

back to top