MathGroup Archive 2005

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

Search the Archive

Re: ExportString[exp, "MathML"]

  • To: mathgroup at smc.vnet.net
  • Subject: [mg61901] Re: [mg61881] ExportString[exp, "MathML"]
  • From: Chris Chiasson <chris.chiasson at gmail.com>
  • Date: Fri, 4 Nov 2005 05:11:22 -0500 (EST)
  • References: <200511030958.EAA26552@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Steven,
Use Unevaluated or HoldForm?
You could try using SetOptions to see if it affects the way
highlight+copy as MathML works.
Please let us know what you decide to do and why.

On 11/3/05, Steven T. Hatton <hattons at globalsymmetry.com> wrote:
> 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
>
>


--
http://chrischiasson.com/contact/chris_chiasson


  • Prev by Date: Re: Pure Function for String Selection
  • Next by Date: Re: How was this typed?
  • Previous by thread: Re: ExportString[exp, "MathML"]
  • Next by thread: Mathematica GuideBooks