MathGroup Archive 2005

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

Search the Archive

ExportString[exp, "MathML"]

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

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" -> {"http://www.w3.org/1998/Math/MathML"; -> 
              "mml"}, "Formats" -> {"PresentationMathML"},
        "Annotations" -> {}
        }]
Then I called it like this
\!\(MMLString[\[Alpha] \[Element] \[DoubleStruckCapitalN] \[Implies]
\[Alpha]\
\^\[Prime] \[Element] \[DoubleStruckCapitalN], "\<peano-2\>"]\)

which resulted in this output:

<mml:math xmlns:mml='http://www.w3.org/1998/Math/MathML'
    xmlns='http://www.w3.org/1998/Math/MathML'
    id='peano-2'>
 <mml:mrow>
  <mml:mrow>
   <mml:mi>&alpha;</mml:mi>
   <mml:mo>&Element;</mml:mo>
   <mml:mi mathvariant='double-struck'>N</mml:mi>
  </mml:mrow>
  <mml:mo>&Implies;</mml:mo>
  <mml:mrow>
   <mml:msup>
    <mml:mi>&alpha;</mml:mi>
    <mml:mo>&prime;</mml:mo>
   </mml:msup>
   <mml:mo>&Element;</mml:mo>
   <mml:mi mathvariant='double-struck'>N</mml:mi>
  </mml:mrow>
 </mml:mrow>
</mml:math>

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='http://www.w3.org/1998/Math/MathML'
    xmlns='http://www.w3.org/1998/Math/MathML'
    id='peano-2'>
 <mml:mn>0</mml:mn>
</mml:math>

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

<mml:math xmlns:mml='http://www.w3.org/1998/Math/MathML'
    xmlns='http://www.w3.org/1998/Math/MathML'
    id='peano-2'>
 <mml:semantics>
  <mml:mrow>
   <mml:ms>&NotExists;&alpha;&Element;N&SuchThat;</mml:ms>
   <mml:msup>
    <mml:ms>&alpha;</mml:ms>
    <mml:ms>&prime;</mml:ms>
   </mml:msup>
   <mml:ms>=0</mml:ms>
  </mml:mrow>
  <mml:annotation encoding='Mathematica'>&quot;\&quot;\[NotExists]\[Alpha]\
\[Element]\[DoubleStruckCapitalN]\[SuchThat]\\!\\(\[Alpha]\\^\[Prime]\\)=\
0\&quot;&quot;</mml:annotation>
 </mml:semantics>
</mml:math>

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"]