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

Online Help

All Products    Maple    MapleSim


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

Calling Sequence

Import( mmlstring )

ImportContent( mmlstring )

ImportModified( mmlstring )

Parameters

mmlstring

-

MathML text in the form of a Maple string

Description

• 

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:

1. 

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

2. 

Content-only MathML encoding.

3. 

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>

    <mrow>

      <mi>b</mi>

      <mo>+</mo>

      <mi>c</mi>

    <mrow/>

  <mrow/>

</math>

  

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="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](..).

Examples

MathMLExporta+2b

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

(1)

MathMLImport

a+2b

(2)

MathMLExportContentIntsinxcosx&comma;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>

(3)

MathMLImportContent

0π2sinxcosx&DifferentialD;x

(4)

odediffyx&comma;xyx2+yxsinxcosx

ode&DifferentialD;&DifferentialD;xyxyx2+yxsinxcosx

(5)

MathMLExportContentode

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

(6)

MathMLImportContent

&DifferentialD;&DifferentialD;xyxyx2+yxsinxcosx

(7)

mmlMathMLExportode&colon;

MathMLImportmml

&DifferentialD;&DifferentialD;xyxyx2+yxsinxcosx

(8)

mmlMathMLExportPresentationode

mml<math xmlns='http://www.w3.org/1998/Math/MathML'><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>

(9)

MathMLImportModifiedmml

&DifferentialD;&DifferentialD;xyxyx2+yxsinxcosx

(10)

See Also

codegen[eqn]

codegen[MathML]

Exporting as MathML

latex

MathML

MathML[Export]

MathML[ExportContent]

Paste MathML

XMLTools