MathML
Import
translate a MathML expression into a Maple expression
ImportContent
translate a content-only MathML expression into a Maple expression
ImportModified
translate a modified MathML expression produced by Maple's GUI into a Maple expression
Calling Sequence
Parameters
Description
Examples
Import( mmlstring )
ImportContent( mmlstring )
ImportModified( mmlstring )
mmlstring
-
MathML text in the form of a Maple string
Importing MathML produces the corresponding Maple expression from a MathML-encoded textual representation of an expression. The MathML-encoded text must be presented to Maple in the form of a Maple string.
Two forms of exported MathML-encoded text are supported by the MathML package for use with the Import routines:
Parallel MathML encoding where both explicit presentation markup and explicit content markup for an expression are represented in a pair of tree data structures, and
Content-only MathML encoding.
Modified-MathML MathML encoding.
A MathML-encoded textual representation of an expression is imported into Maple by using one among the routines Import (to import a parallel MathML encoding), ImportContent (to import a content-only MathML encoding) and ImportModified (to import a modified MathML encoding).
Each of these routines accepts a Maple string containing MathML-encoded text. (The strings are assumed to be valid MathML.) If the translation from MathML to Maple is possible, the corresponding Maple expression is returned. Otherwise, an exception is raised.
Importing content-only MathML by using MathML[ImportContent] is a reasonably fast and accurate operation.
Presentation-only MathML, which is intended for renderers and not designed for computation tools like Maple, is highly ambiguous and frequently cannot be translated accurately. As a result, it is sometimes not possible for Maple's MathML[Import] routine to make any sense of valid presentation-only MathML. For more information, see Export as HTML or HTML with MathML.
Note: Heuristic preprocessing, heuristic parsing, and some simple AI techniques are used to attempt the translation from presentation MathML to Maple. When multiple possibilities exist for a translation, a choice must be made. For example, the MathML fragment
<math>
<mrow>
<mi>a</mi>
<mi>b</mi>
<mo>+</mo>
<mi>c</mi>
<mrow/>
</math>
can be validly and reasonably interpreted either as a⁡b+c (a function call) or as a⁢b+c (a product).
It is also possible to construct, using MathML, expressions that have no meaningful representation within Maple (such as the valid C language expression "a + ++b").
Because Maple routinely deals with a much wider class of expressions than can be validly encoded in standard MathML, in some cases, Maple's graphical user interface uses a proper extension of standard presentation MathML, termed here "modified MathML". The ImportModified command allows you to import this extended form of MathML produced by Maple's GUI, and should be used for all MathML expressions that have their origin in Maple's GUI (for example, expressions returned from a worksheet embedded component). Operationally, it is identical to the Import command. However, the ImportModified command is restricted to (extended) presentation-only MathML, and does not handle parallel (mixed) MathML markup.
The Import command accepts a source option which can be optionally set to one of "maple", "calculator", "content", or "oem". The default is source="content" is the original import method for this command. The source="maple" option should be used to re-import MathML that was generated by MathML[Export]. The source="calculator" option can be used to import MathML using the same rules applied by the Maple Calculator. The source="oem" option uses an alternate implementation used by an independent text-book publisher. These methods all use different heuristics for determining what parentheses, commas, and other symbols mean.
The Import command accepts an output option which can be optionally set to one of "expression", "string", "worksheet", or "inert". The default is output="expression", for which the Import command will return a Maple expression. Using output="string" is similar, returning a Maple expression as a parseable string using Maple's expression syntax. The output="inert" option returns an expression with operators and function names made inert. The output="worksheet" command can be used in conjunction with filename="File.mw" to generate a Maple worksheet containing the given expression.
This function is part of the MathML package, and so it can be used in the form Import(..) only after executing the command with(MathML). However, it can always be accessed through the long form of the command by using the form MathML[Import](..).
MathMLExport⁡a+2⁢b
<math xmlns='http://www.w3.org/1998/Math/MathML'><semantics><mrow xref='id5'><mi xref='id1'>a</mi><mo>+</mo><mrow xref='id4'><mn xref='id2'>2</mn><mo>⁢</mo><mi xref='id3'>b</mi></mrow></mrow><annotation-xml encoding='MathML-Content'><apply id='id5'><plus/><ci id='id1'>a</ci><apply id='id4'><times/><cn id='id2' type='integer'>2</cn><ci id='id3'>b</ci></apply></apply></annotation-xml><annotation encoding='Maple'>a+2*b</annotation></semantics></math>
MathMLImport⁡
a+2⁢b
MathMLExportContent⁡Int⁡sin⁡x−cos⁡x,x=0..π2
<math xmlns='http://www.w3.org/1998/Math/MathML'><apply id='id13'><int/><bvar><ci id='id5'>x</ci></bvar><lowlimit><cn id='id1' type='integer'>0</cn></lowlimit><uplimit><apply id='id4'><times/><cn id='id2' type='rational'>1<sep/>2</cn><pi id='id3'/></apply></uplimit><apply id='id12'><minus/><apply id='id8'><sin id='id6'/><ci id='id7'>x</ci></apply><apply id='id11'><cos id='id9'/><ci id='id10'>x</ci></apply></apply></apply></math>
MathMLImportContent⁡
∫0π2sin⁡x−cos⁡xⅆx
ode≔diff⁡y⁡x,x−y⁡x2+y⁡x⁢sin⁡x−cos⁡x
ode≔ⅆⅆxy⁡x−y⁡x2+y⁡x⁢sin⁡x−cos⁡x
MathMLExportContent⁡ode
<math xmlns='http://www.w3.org/1998/Math/MathML'><apply id='id21'><plus/><apply id='id5'><diff/><bvar><ci id='id1'>x</ci></bvar><apply id='id4'><ci id='id2'>y</ci><ci id='id3'>x</ci></apply></apply><apply><minus/><apply id='id10'><power/><apply id='id8'><ci id='id6'>y</ci><ci id='id7'>x</ci></apply><cn id='id9' type='integer'>2</cn></apply></apply><apply id='id17'><times/><apply id='id13'><ci id='id11'>y</ci><ci id='id12'>x</ci></apply><apply id='id16'><sin id='id14'/><ci id='id15'>x</ci></apply></apply><apply><minus/><apply id='id20'><cos id='id18'/><ci id='id19'>x</ci></apply></apply></apply></math>
ⅆⅆxy⁡x−y⁡x2+y⁡x⁢sin⁡x−cos⁡x
mml≔MathMLExport⁡ode:
MathMLImport⁡mml
mml≔MathMLExportPresentation⁡ode
mml≔<math xmlns='http://www.w3.org/1998/Math/MathML'><mrow><mrow><mfrac><mo>ⅆ</mo><mrow><mo>ⅆ</mo><mi>x</mi></mrow></mfrac><mrow><mi>y</mi><mo>⁡</mo><mfenced><mi>x</mi></mfenced></mrow></mrow><mo>-</mo><msup><mrow><mi>y</mi><mo>⁡</mo><mfenced><mi>x</mi></mfenced></mrow><mn>2</mn></msup><mo>+</mo><mrow><mrow><mi>y</mi><mo>⁡</mo><mfenced><mi>x</mi></mfenced></mrow><mo>⁢</mo><mrow><mi>sin</mi><mo>⁡</mo><mfenced><mi>x</mi></mfenced></mrow></mrow><mo>-</mo><mrow><mi>cos</mi><mo>⁡</mo><mfenced><mi>x</mi></mfenced></mrow></mrow></math>
MathMLImportModified⁡mml
See Also
codegen[eqn]
codegen[MathML]
Exporting as MathML
latex
MathML[Export]
MathML[ExportContent]
Paste MathML
XMLTools
Download Help Document