4.6 Other Elements

 < Day Day Up > 



4.6 Other Elements

For most of the presentation elements discussed in this chapter, the rendering rules are determined by the standard conventions of mathematical notation. However, two presentation elements, maction and merror, do not correspond to any type of mathematical notation. This section explains the meaning and usage of these two elements.

Setting up Actions

The maction element provides a mechanism for adding interactivity to MathML equations. This element associates a type of action with an MathML expression. You can then program a processing application to perform the specified action in response to a user event (such as clicking or moving the mouse over the MathML expression).

An maction element can contain any other MathML elements and can have any number of arguments. This element has the following two attributes:

  • selection : is an integer that identifies one of the arguments of the maction element. The value 1 refers to the first argument, 2 to the second argument, and so on. This attribute provides a way to refer to subexpressions of the maction element-for example, in cases where the intended action is to toggle between different subexpressions. The argument of the maction element that corresponds to the specified value of the selection attribute is called the selected subexpression.

  • actiontype : specifies the action to be performed. The allowed values of this attribute are not defined by the MathML specification. Instead, each MathML application is expected to define its own values depending on the type of actions it supports.

Some examples of possible values of actiontype along with the actions associated with them are given below. Note that all these example are hypothetical. They are provided only to illustrate the concept. For these values of the actiontype attribute to work as indicated, they must first be implemented by a specific application. A MathML application that does not recognize a value specified for actiontype will just render the selected subexpression without performing the action.

With actiontype="toggle", a rendering application would display one of a given series of subexpressions. Each time the user clicks the displayed subexpression, the renderer would update the value of selection by 1 and cause the next expression in the series to be displayed. Here is an example illustrating this behavior:

    <maction actiontype=toggle selection=1>      (expression1)      (expression2)      </maction> 

With actiontype="statusline", clicking or moving the mouse over an expression would cause the specified message to appear in the status line of the browser, as shown here:

    <maction actiontype="statusline">      (expression)      (message)    </maction> 

With actiontype="tooltip", clicking or moving the mouse over an expression would cause the message to be displayed in a pop-up tooltip box near the expression, as follows:

    <maction actiontype="tooltip">      (expression)      (message)    </maction> 

With actiontype="highlight", clicking or moving the mouse over an expression would cause the message to be displayed in a different color and/or with a different background, as shown here:

    <maction actiontype="highlight" xhtml:color="red"       xhtml:background="yellow">     expression    </maction> 

In the above example, the color and background are specified by two other attributes from a different namespace.

With actiontype="menu", clicking or moving the mouse over an expression would cause a pop-up menu to be displayed. A typical MathML expression using this attribute would have the following structure:

    <maction actiontype="menu" selection="1">      (menu item 1)      (menu item 2)    </maction> 

The items in the menu above are determined by the arguments of the <maction> element. Since a <maction> element can contain any other MathML elements, each menu item could itself be a MathML expression, to allow a user to choose from different forms of an expression.

Displaying Error Messages

The merror element displays its contents as an error message. It is intended as a way of displaying syntax errors encountered when an application is generating MathML from some other form of input. Each application can choose its own style for displaying the contents of the merror element so they are easy to distinguish from the surrounding text (for example, in a different color or with a different background).

The suggested use of the merror element is for an application to replace the erroneous part of the input with an merror element that contains a description of the error. The application then continues processing the surrounding input as normally as possible. This way, the error message appears at the location where the erroneous input would have appeared, making it easier to identify the cause of the error.

The merror element can contain any arbitrary MathML expression. Typically the text of the error message is enclosed in an mtext element. If the erroneous input contains fragments that are correctly formatted, then these can be processed normally and included in the contents of the error message.

For example, suppose a user includes the MathML element mssub instead of the MathML element msub because of a typing error, as shown in the following markup:

    <mssub>      <mi>&ExponentialE;</mi>      <mrow>        <mi>&ImaginaryI;</mi>        <mi>&InvisibleTimes;</mi>        <mi>&pi;</mi>      </mrow>    </mssub> 

When this markup is processed by an application that checks for MathML syntax, an error message like the following might be produced:

    <merror>     <mtext>Unrecognized element at line       17:mssub;arguments were:</mtext>         <mi>&ExponentialE;</mi>     <mtext>and</mtext>       <mrow>         <mi>&ImaginaryI;</mi>         <mi>&InvisibleTimes;</mi>         <mi>&pi;</mi>       </mrow>    </merror> 



 < Day Day Up > 



The MathML Handbook
The MathML Handbook (Charles River Media Internet & Web Design)
ISBN: 1584502495
EAN: 2147483647
Year: 2003
Pages: 127
Authors: Pavi Sandhu

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net