W3C home > Mailing lists > Public > www-math@w3.org > July 2003

Re: correct/simplify Content MathML

From: Max Froumentin <mf@w3.org>
Date: Tue, 08 Jul 2003 16:04:13 +0200
To: "Ana Skupch" <anaskupch@cecilija.zesoi.fer.hr>
Cc: <www-math@w3.org>
Message-ID: <87vfudnmhu.fsf@w3.org>

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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Saturday, 20 February 2010 06:12:55 GMT