Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*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

Re: ExportString[exp, "MathML"]

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

At 03:58 AM 11/3/2005, Steven T. Hatton wrote:

>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.

1) Use HoldForm around the first argument to ExportString.  In 
addition, make sure the expression isn't evaluated before it gets to 
ExportString by using the standard evaluation inhibitors like 
Unevaluated or make your export function HoldFirst.
2) Use the "IncludeMarkupAnnotations" -> False conversion option.

Here is an updated version of your function and your example input/output:

MMLString[exp_, id_String] :=
   ExportString[HoldForm[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" -> {}, "IncludeMarkupAnnotations" -> False
         }]

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

<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:mrow>
     <mml:mi>NotExists</mml:mi>
     <mml:mo>&ApplyFunction;</mml:mo>
     <mml:mo>(</mml:mo>
     <mml:mrow>
      <mml:mi>&alpha;</mml:mi>
      <mml:mo>&Element;</mml:mo>
      <mml:mi mathvariant='double-struck'>N</mml:mi>
     </mml:mrow>
     <mml:mo>)</mml:mo>
    </mml:mrow>
    <mml:mo>&SuchThat;</mml:mo>
    <mml:msup>
     <mml:mi>&alpha;</mml:mi>
     <mml:mo>&prime;</mml:mo>
    </mml:msup>
   </mml:mrow>
   <mml:mo>=</mml:mo>
   <mml:mn>0</mml:mn>
  </mml:mrow>
</mml:math>

Chris Hill
Wolfram Research 


  • Prev by Date: Re: Error: Prime::intpp: Positive integer argument expected in Prime[16.`]
  • Next by Date: Re: Re: How was this typed?
  • Previous by thread: Re: ExportString[exp, "MathML"]
  • Next by thread: Re: ExportString[exp, "MathML"]