Up-Conversion Failure Handling

As we have mentioned, the up-conversion process only works with certain LaTeX inputs. If the process cannot convert a certain input to Content MathML or Maxima, then SnuggleTeX continues as normal, recording information about why it cannot perform the up-conversion as an annotation in the resulting MathML.

Failure to generate Content MathML

Consider the following example:

a==2

While this might make sense in certain programming languages, the up-conversion process has not been taught to handle two adjacent relation operators so fails to convert this input to Content MathML.

The result will be an annotated MathML element containing the (enhanced) Presentation MathML and a special <annotation-xml/> element hopefully revealing where the conversion to Content MathML failed:

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
   <semantics>
      <mrow>
         <mn>1</mn>
         <mo>=</mo>
         <mrow>
            <mo>=</mo>
            <mn>2</mn>
         </mrow>
      </mrow>
      <annotation-xml encoding="MathML-Content-upconversion-failures">
         <s:fail xmlns:s="https://www.ph.ed.ac.uk/snuggletex" code="UCFOP4"
                 message="Unsupported grouping of relation operators">
            <s:xpath>mrow[1]/mo[1]</s:xpath>
            <s:context>
               <mo>=</mo>
               <mn>2</mn>
            </s:context>
         </s:fail>
      </annotation-xml>
   </semantics>
</math>

The failure code(s) will all have the form UCFxxx when up-conversion to Content MathML fails. These are listed in the SnuggleTeX Error Codes page. (Do however note that these are not reported the same way as parsing or DOM-building errors.)

The <s:context/> indicates the problematic Presentation MathML Element(s) that this failure refers to, and the <s:xpath/> gives the location of the first of these Elements relative to the root of the Presentation MathML as an XPath expression. (This expression assumes that the default namespace is the MathML namespace.)

Failure to generate Maxima Input

Generating Maxima Input syntax requires the conversion to Content MathML to succeed, so if that part of the process fails then so will the conversion to Maxima Input syntax. On the other hand, many inputs will generate Content MathML which cannot then be converted into a sensible Maxima form.

Consider the following example:

1_a

This generates the following MathML:

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
   <semantics>
      <msub>
         <mn>1</mn>
         <mi>a</mi>
      </msub>
      <annotation-xml encoding="MathML-Content">
         <ci>
            <msub>
               <mn>1</mn>
               <mi>a</mi>
            </msub>
         </ci>
      </annotation-xml>
      <annotation-xml encoding="Maxima-upconversion-failures">
         <s:fail xmlns:s="https://www.ph.ed.ac.uk/snuggletex" code="UMFG04"
                 message="Cannot create subscripted variable">
            <s:xpath>ci[1]</s:xpath>
            <s:context>
               <ci>
                  <msub>
                     <mn>1</mn>
                     <mi>a</mi>
                  </msub>
               </ci>
            </s:context>
         </s:fail>
      </annotation-xml>
   </semantics>
</math>

Here, the Maxima-related failures are contained within an <annotation-xml/> element with encoding Maxima-upconversion-failures and all have codes of the form UMFxxx.

Similarly, the <s:context/> indicates the problematic Content MathML Element(s) that this failure refers to, and the <s:xpath/> gives the location of the first of these Elements relative to the root of the Content MathML as an XPath expression. (This expression assumes that the default namespace is the MathML namespace.)

Extracting Up-Conversion Failure Information

You can extract details of any up-conversion failures from an annotated MathML Element or Document using the utility method UpConversionUtilities.extractUpConversionFailures(). This returns a List of UpConversionFailure Objects than can be interrogated or converted to error messages.