Import - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim





translate a MathML expression into a Maple expression




translate a content-only MathML expression into a Maple expression




translate a modified MathML expression produced by Maple's GUI into a Maple expression


Calling Sequence




Calling Sequence

Import( mmlstring )

ImportContent( mmlstring )

ImportModified( 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












can be validly and reasonably interpreted either as ab+c (a function call) or as ab+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="" 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](..).



<math xmlns=''><semantics><mrow xref='id5'><mi xref='id1'>a</mi><mo>+</mo><mrow xref='id4'><mn xref='id2'>2</mn><mo>&InvisibleTimes;</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>






<math xmlns=''><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>









<math xmlns=''><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>










mml<math xmlns=''><mrow><mrow><mfrac><mo>&DifferentialD;</mo><mrow><mo>&DifferentialD;</mo><mi>x</mi></mrow></mfrac><mrow><mi>y</mi><mo>&ApplyFunction;</mo><mfenced><mi>x</mi></mfenced></mrow></mrow><mo>-</mo><msup><mrow><mi>y</mi><mo>&ApplyFunction;</mo><mfenced><mi>x</mi></mfenced></mrow><mn>2</mn></msup><mo>+</mo><mrow><mrow><mi>y</mi><mo>&ApplyFunction;</mo><mfenced><mi>x</mi></mfenced></mrow><mo>&InvisibleTimes;</mo><mrow><mi>sin</mi><mo>&ApplyFunction;</mo><mfenced><mi>x</mi></mfenced></mrow></mrow><mo>-</mo><mrow><mi>cos</mi><mo>&ApplyFunction;</mo><mfenced><mi>x</mi></mfenced></mrow></mrow></math>





See Also



Exporting as MathML





Paste MathML