Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

ExportString[exp, "MathML"]

  • To: mathgroup at
  • Subject: [mg61881] ExportString[exp, "MathML"]
  • From: "Steven T. Hatton" <hattons at>
  • Date: Thu, 3 Nov 2005 04:58:50 -0500 (EST)
  • Sender: owner-wri-mathgroup at

I created a function as follows:
MMLString[exp_, id_String] := 
  ExportString[exp, "MathML", 
    ConversionOptions -> {"MathAttributes" -> {"id" -> id}, 
        "UseUnicodePlane1Characters" -> False, "Entities" -> {"MathML",
            "\[Implies]" -> "&Implies;",
            "\[SuchThat]" -> "&SuchThat;"
        "NamespacePrefixes" -> {""; -> 
              "mml"}, "Formats" -> {"PresentationMathML"},
        "Annotations" -> {}
Then I called it like this
\!\(MMLString[\[Alpha] \[Element] \[DoubleStruckCapitalN] \[Implies]
\^\[Prime] \[Element] \[DoubleStruckCapitalN], "\<peano-2\>"]\)

which resulted in this output:

<mml:math xmlns:mml=''
   <mml:mi mathvariant='double-struck'>N</mml:mi>
   <mml:mi mathvariant='double-struck'>N</mml:mi>

Which was exactly what I wanted.

Note, however, that I passed a "raw" expression, not a string.  That's fine
for an expression that would evaluate to something else.  But I now need to
convert this:

\!\(MMLString[\[NotExists] \[Alpha] \[Element] \[DoubleStruckCapitalN] \
\[SuchThat] \[Alpha]\^\[Prime] = 0, "\<peano-2\>"]\)

That gives:
<mml:math xmlns:mml=''

because the expression evaluated to 0.  If I pass it as a string, I get:

<mml:math xmlns:mml=''
  <mml:annotation encoding='Mathematica'>&quot;\&quot;\[NotExists]\[Alpha]\

which has two problems.  First of all, notice that the
\[DoubleStruckCapitalN] is no longer represented as <mml:mi
mathvariant='double-struck'>N</mml:mi>.  That needs to be corrected.  The
second problem is all the Mathematica annotation.  I don't need that, nor
do I want it.  

So, 1) how do I convert the expression to MathML, without having it evaluate
to 0? There is a small caveat. In Mathematica terminology, that is really
trying to do an assignment, so it doesn't make sense as a Mathematica
expression to have the '='. A '==' would make more sense for an expression. 
In this case, however, I want to present the expression in traditional
mathematical notation. 2) How do I prevent Mathematica from tacking on its
own annotations?  As I say, I neither need nor want them.

"Philosophy is written in this grand book, The Universe. ... But the book
cannot be understood unless one first learns to comprehend the language...
in which it is written. It is written in the language of mathematics, ...;
without which wanders about in a dark labyrinth."   The Lion of Gaul

  • Prev by Date: Mathematica and Excel
  • Next by Date: Re: 2.9.2 How Input and Output Work
  • Previous by thread: Mathematica and Excel
  • Next by thread: Re: ExportString[exp, "MathML"]