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]" -> "⇒", "\[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>α</mml:mi> <mml:mo>∈</mml:mo> <mml:mi mathvariant='double-struck'>N</mml:mi> </mml:mrow> <mml:mo>⇒</mml:mo> <mml:mrow> <mml:msup> <mml:mi>α</mml:mi> <mml:mo>′</mml:mo> </mml:msup> <mml:mo>∈</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>∄α∈N∋</mml:ms> <mml:msup> <mml:ms>α</mml:ms> <mml:ms>′</mml:ms> </mml:msup> <mml:ms>=0</mml:ms> </mml:mrow> <mml:annotation encoding='Mathematica'>"\"\[NotExists]\[Alpha]\ \[Element]\[DoubleStruckCapitalN]\[SuchThat]\\!\\(\[Alpha]\\^\[Prime]\\)=\ 0\""</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
- Follow-Ups:
- Re: ExportString[exp, "MathML"]
- From: Chris Chiasson <chris.chiasson@gmail.com>
- Re: ExportString[exp, "MathML"]
- From: Chris Hill <chill@wolfram.com>
- Re: ExportString[exp, "MathML"]