5 mo
A translation of
<math:mrow>
<math:mn>2</math:mn>
<math:mo>+</math:mo>
</math:mrow>
to
<math:mrow>
<math:mn>2</math:mn>
<math:mo form="postfix">+</math:mo>
</math:mrow>
fails to satisfy OO. So the following alternative is offered
<math:mrow>
<math:mn>2</math:mn>
<math:mtext>+</math:mtext>
</math:mrow>
<xsl:when test="
(preceding-sibling::math:mn or preceding-sibling::math:mi)
and not(following-sibling::*)
" >
<math:mtext>
<xsl:apply-templates select="*|@*|text()" />
</math:mtext>
</xsl:when>
-_-_-
Isolated mo elements are problematic (e.g., <mtd><mo form="...">=</mo></mtd>) in
OpenOffice (http://lists.w3.org/Archives/Public/www-_math/2006Jul/0012.html)
so they are converted into mtext elements.
<xsl:when test="
not((preceding-sibling::*) or following-sibling::*)
" >
<math:mtext>
<xsl:apply-templates select="*|@*|text()" />
</math:mtext>
</xsl:when>
-_-_-
The original condition ‘not(preceding-sibling::* or following-sibling::*)’ failed with
java 1.6 at a MS OS.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xlink="http://www.w3.org/1999/xlink"
>
<xsl:output omit-xml-declaration = "yes" />
<xsl:template match="mo" >
<xsl:choose>
<xsl:when test="preceding-sibling::* or following-sibling::*" >
</xsl:when>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
import java.io.*;
import javax.xml.transform.*;
import javax.xml.transform.stream.*;
public class Test {
public static void main(String[] args)
throws TransformerConfigurationException,
TransformerException {
try{
StreamSource xslt = new StreamSource(new File("test.xslt"));
TransformerFactory fc = TransformerFactory.newInstance();
Transformer transformer = fc.newTransformer( xslt );
} catch (javax.xml.transform.TransformerConfigurationException e){
} catch (Exception e){
System.err.println(e);
} } }
Failes on braces within mo elements <math:mo>{</math:mo>. Accepts them
within mtext elements.
<xsl:when test="
(.=’{’) or (.=’}’)
" >
<math:mtext>
<xsl:apply-templates select="*|@*|text()" />
</math:mtext>
</xsl:when>
-_-_-
A \begin{eqnarray}a&=&b\end{eqnarray} is translated by tex4ht into
<mi>a</mi><mo>=</mo><mi>b</mi>
and is loaded as
matrix {a # = # b}
by OO2 into a broken display. The xtpipe phase ‘fixes’ the problem by
producing improper mathml output
<mi>a</mi><mtext>=</mtext><mi>b</mi>
which OO2 loads as
matrix {a # "=" # b}
and provides proper display.
<xsl:when test=" . = ’=’" >
<xsl:choose>
<xsl:when test=" not(preceding-sibling::*)
or not(following-sibling::*)
or preceding-sibling::*[1] / self::math:mo
">
<math:mtext>
<xsl:apply-templates select="*|@*|text()" />
</math:mtext>
</xsl:when>
<xsl:otherwise>
<math:mo>
<xsl:apply-templates select="*|@*|text()" />
</math:mo>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
-_-_-
In cases like $m \bmod n$, OpenOffice swallos the characters following the first
one.
<xsl:when test=" string-length() > 1 " >
<math:mtext>
<xsl:value-of select="normalize-space(.)" />
</math:mtext>
</xsl:when>
-_-_-