Re: correct/simplify Content MathML

Hi Ana,

"Ana Skupch" <anaskupch@cecilija.zesoi.fer.hr> wrote:

> I thought of writing an XSL for myself, but I would need to convert
> prefix (from MathML) to infix notation and this seems pretty
> difficult to me.

Because XSLT is recursive it's actually not so difficult

<xsl:template match="apply">
  <xsl:text>(</xsl:text>
  <xsl:apply-templates select="*[2]"/>
  <xsl:apply-templates select="*[1]"/>
  <xsl:apply-templates select="*[3]"/>
  <xsl:text>)</xsl:text>
</xsl:template>

<xsl:template match="plus">+</xsl:template>
<xsl:template match="ci"><xsl:apply-templates/></xsl:template>

Would work with your example.

The real difficulty lies with characters, espeially if you want to
convert &#x345F; to \lambda, if you output TeX.

You could also do the simplification in XSLT itself. I remember writing
templates to transform x+0 to x, or similar trivial ones. Of course this
will get you nowhere near the power of Mathematica or Maple, but it was
fun to write.

Cheers,

Max.

Received on Tuesday, 8 July 2003 10:05:11 UTC