IBM techexplorer

(Excerpt from "The MathML Handbook" by Pavi Sandhu)

IBM techexplorer is designed to be a general purpose rendering application for scientific documents that can interpret and display TeX and LaTeX markup as well as MathML. As discussed under Displaying MathML in web browsers: Add-on software: IBM techexplorer, the markup to be rendered by techexplorer is inserted into an HTML document using either an embed tag (for Netscape) or object tag (for IE). A better solution is to place the embed tag inside the object tag. This ensures that the markup can be rendered in both Netscape and IE. Here is an example:

<object name="techexplorer" classid="clsid:5AFAB315-AD87-11D3-98BB-002035EFB1A4" width="200" height="100">
  <param name="DataType" value="1" />
  <param name="Data" value="string" />
  <embed name="techexplorer" type="application/x-techexplorer" mmldata="string" width="200" height="100"></embed>
</object>

techexplorer also provides support for interactivity in two ways. You can directly author a number of equation actions (such as toggling between two displays or creating links) using built-in techexplorer commands. In addition, you can use the built-in class libraries and API functions in conjunction with JavaScript or Java programs to interactively control techexplorer in response to user input. We shall see some examples of both types of interactivity in this section.

Actions in techexplorer

techexplorer supports a number of special commands that you can insert into a document to implement specific features, such as creating hyperlinks, opening pop-up windows or menus, and toggling between two different expressions. The name and syntax of techexplorer commands are modeled on those of LaTeX. Most commands take the form \commandname{arg1}...{argn}. The name of the command is preceded by a slash(\) and followed by one or more arguments, each of which is enclosed in curly brackets.

Here are some of the important techexplorer commands for implementing actions:

  • \doclink{url}{expression}: creates a hyperlink to the URL specified by url. Here, expression specifies the content to be rendered by techexplorer.
  • \doclink{url}{label}{expression}: links to the specified URL and causes the window to scroll to the position indicated by label. If the label is not found, the window is positioned at the top of the document.
  • \labellink{label}{expression}: creates a hyperlink to another part of the same document.
  • \labellink{label}: defines the target of the links defined by \doclink{url}{label}{expression} and \labellink{label}{expression}.
  • \popuplink{ popupText}{caption}{expression}: causes a pop-up window to appear with popupText displayed in the window and caption in its title bar. This feature is useful for adding footnotes in a document.
  • \altlink{expression1}{expression2}: toggles between the display of expression1 and expression2 each time a user clicks the displayed expression.

These commands can be freely interspersed with the markup to be rendered by techexplorer. However, most of these commands do not work with MathML markup. If you want to implement equation actions using these commands, you must encode all mathematical expressions in LaTeX format.

Scripting techexplorer

The Professional version of techexplorer contains a set of APIs. These consist of several class libraries with functions that JavaScript and Java programs can access to control techexplorer and implement interactive behavior. The following table shows a selected list of the API functions that techexplorer makes available to external programs.

Table: API functions that techexplorer makes available to external programs.

Method Description
getMMLString( ) Returns the MathML data displayed in the techexplorer window.
reloadFromMMLString(String mmlSource) Replaces the document with the supplied MathML source.
getWidthFromMMLString(String mmlSource) Returns the width of a MathML expression.
getHeightFromMMLString(String mmlSource) Returns the height of a MathML expression.
getDepthFromMMLString(String mmlSource) Returns the depth of a MathML expression.
convertMMLtoTeX( ) Converts the document from MathML source to TeX.
convertTeXtoMML( ) Converts the document from TeX source to MathML.

The following example illustrates the use of the techexplorer API functions to implement interactive behavior in a Web page. It shows an HTML document that contains a text area and a button. A user can enter a MathML expression in the text area and then click the button to render the MathML using techexplorer.

Example: An HTML document for rendering MathML expressions using techexplorer.

<html>
  <head>
    <title>IBM techexplorer</title>
    <script language="JavaScript">
      function displayMML( ) {
        var expr = document.MMLForm.MMLString.value
        document.te.reloadFromMMLString(expr);
        document.MMLForm.MMLString.value=
        document.te.getMMLString();
      }
    </script>
  </head>
  <body bgcolor="white">
    <h1>techexplorer scripting example</h1>
    <p>Enter MathML string:</p>
    <p>
      <form name="MMLForm"><textarea name="MMLString" ROWS="10" COLS="30"></textarea></form>
    </p>
    <p><input type="button" name="MMLSend" value="Display in techexplorer" onClick="displayMML()" /></p>
    <p>
      <object name="te" classid="clsid:5AFAB315-AD87-11D3-98BB-002035EFB1A4" width="500" height="80">
        <param name="DataType" value="0" />
        <param name="Data" value="Equation will be displayed here." />
        <embed name="te" type="application/x-techexplorer" mmldata="Equation will be displayed here" width="400" height="100"></embed>
      </object>
    </p>
  <body>
</html>

The HTML document of the example above has the following features. The "Display in techexplorer" button calls the JavaScript function displayMML. This function reads the MathML expression entered by the user and passes it as the argument of the reloadFromMMLString function. This function causes the techexplorer window in the Web page to be redrawn so that the MathML markup entered by the user is rendered in the page (see the following figure). This example is the techexplorer equivalent of the example An HTML document for rendering a specified MathML expression, which also renders a MathML expression but using the WebEQ Viewer Control. The reloadfromMMLString function in techexplorer is analogous to the setEquation function in the WebEQ Viewer Control.

techexplorer rendering arbitrary MathML expression

Figure: Viewing the techexplorer rendering of an arbitrary MathML expression.

One of the useful features of techexplorer is that it can interpret and render LaTeX markup in addition to MathML. The techexplorer API includes functions for converting between LaTeX and MathML. Thus, you can easily modify the example above to set up a Web page that allows users to type in the LaTeX markup for a formula and convert it to MathML, or the other way around. For example, LaTeX users who want to convert existing equations in their documents into MathML for posting on the Web can use this type of tool. The following example shows an HTML document that implements this type of conversion.

Example: An HTML document for converting between MathML and LaTeX.

<html>
  <head>
    <title>IBM techexplorer</title>     
    <script language="javascript">
      function submitMML( ) {
        document.te.reloadFromMMLString(
        document.MMLForm.MMLString.value);
        document.MMLForm.MMLString.value=
        document.te.getMMLString() 
        document.TeXForm.TeXString.value=
        document.te.convertMMLtoTeX()
      }
      function submitTeX( ) {
        document.te.reloadFromTeXString(
        document.TeXForm.TeXString.value); 
        document.TeXForm.TeXString.value=
        document.te.getTeXString() 
        document.MMLForm.MMLString.value=
        document.te.convertTeXtoMML()
      }
    </script>
  </head>
  <body bgcolor="white">
    <h1>techexplorer scripting example</h1>
    <table>
      <tr>
        <td>Enter MathML string:</td>
        <td>Enter LaTeX string:</td></tr>
      <tr>
        <td><form name="MMLForm"><textarea name="MMLString" rows=10 cols=30></textarea></form></td>
        <td><form name="TeXForm"><textarea name="TeXString" rows=10 cols=30></textarea></form></td>
      </tr>
      <tr>
        <td><form><input type="button" name="MMLSend" value="Convert to LaTeX" onclick="submitMML()"></form></td>
        <td><form><input type="button" name="TeXSend" value="Convert to MathML" onclick="submitTeX()"></form></td>
      </tr>
    </table>
    <object name="te" classid="clsid:5AFAB315-AD87-11D3-98BB-002035EFB1A4">
      <param name="AutoSize" value="true" />
      <param name="DataType" value="1" />
      <param name="Data" value="<math><mrow></mrow></math>" />
      <embed name="te" type="application/x-techexplorer" mmldata="<math><mrow></mrow></math>" width="200" height="100"></embed>
    </object>
  </body>
</html>

The document in the above example contains two text areas, two buttons, and a techexplorer window. One of the text areas is for entering MathML markup, and the other is for entering LaTeX markup. Below each text area is a button for converting the markup contained in that text area from one format to the other. For example, suppose you type in a LaTeX expression in the text area with the name TeXString and then click the button marked "Convert to MathML". This calls the JavaScript function submitTeX, which uses the convertTeXtoMML function to translate the LaTeX markup into MathML. The resulting MathML expression is then displayed in the MathML text area, and the equation is rendered in the techexplorer window as well (see the following figure).

Converting between MathML and LaTeX using techexplorer

Figure: Converting between MathML and LaTeX encodings of a formula using techexplorer.

   

<< back next >>

 

 

 


 

Copyright © CHARLES RIVER MEDIA, INC., Massachusetts (USA) 2003
Printing of the online version is permitted exclusively for private use. Otherwise this chapter from the book "The MathML Handbook" is subject to the same provisions as those applicable for the hardcover edition: The work including all its components is protected by copyright. All rights reserved, including reproduction, translation, microfilming as well as storage and processing in electronic systems.


CHARLES RIVER MEDIA, INC., 20 Downer Avenue, Suite 3, Hingham, Massachusetts 02043, United States of America