| Mappings between Presentation Markup and Semantic Markup for Variable-Size Objects
Bill Naylor
In this paper we give a brief overview of the paper "meta stylesheets for the Conversion of Mathematical Documents into Multiple forms" [1]. We propose an extension to the techniques proposed in [1] in order to overcome the problem of specifying notation for objects of a varying size, e.g. matrices or vectors. The extensions proposed in this paper are based on regular expression or XML Schema like ideas. We discuss the basics of using XSLT for performing the calculations defined by the template functions. We discuss how we may use the document element to access external processes which may be required to perform calculations for which XSLT is ill-suited. Finally, we suggest a way in which a user of the extended MathML we propose may specify different notation styles at different levels within an object.
1 Introduction
It is an unfortunate fact that due to the varied history of
mathematics, mathematical notation is ambiguous. There is a many to
many relationship between the meaning of a mathematical object and the
notation which mathematicians use to write them down (as noted in
chapter 4 of the MathML specification [2]). A document
marked up using the OpenMath ([4] and [3])
markup language is a possible alternative approach which does not
suffer from this problem. However, the OpenMath concept does not
address the issue of presentation markup. Ideally, we want some markup
which gives flexible presentation markup for semantically unambiguous
mathematics.
Example: 1
We give an example of the entries to the notation element for the
BesselJ symbol, which detail the notations given in the traditional
style;
, and that used by Maple 7;
BesselJ(n,m):
<Notation>
<version precedence="10"> <!-- The default style
-->
<math><mrow>
<msub><mi>J</mi>
<mrow>
<value xref="arg1">ν</value>
</mrow>
</msub>
<mo>⁡</mo>
<mfenced>
<value xref="arg2">z</value>
</mfenced>
</mrow></math>
</version>
<version precedence="10" style="maple"> <!-- The Maple
Notation -->
<math><mrow>
<mi>BesselJ</mi><mo>⁡</mo>
<mfenced>
<value xref="arg1">n</value>
<value xref="arg2">z</value>
</mfenced>
</mrow></math>
</version>
<semantic_template><OMOBJ>
<OMA><OMS cd="bessel" name="BesselJ"/>
<OMV name="nu" id="arg1"/>
<OMV name="x" id="arg2"/>
</OMA>
</OMOBJ></semantic_template>
</Notation>
Occasionally it occurs that part of the presentation for a notation for a particular symbol do not correspond to a particular part of the prototype of the semantic template, for example the superscript n in the partial derivative presentation:
is redundant, (implicitly Example: 2
In this example we assume the availability of the Notation
element
given in example 1. An author may select the Maple
style of
notation by giving the following markup. It should be noted that the
ordering of the parameters will be as given in the respective content
dictionary. The following shall be displayed as
BesselJ(1,2):1
<xm:apply><xm:BesselJ style="maple"/> <xm:mn> 1 </xm:mn> <xm:mn> 2 </xm:mn> </xm:apply> It would appear that these mechanisms are sufficient for providing a presentation/semantics mapping for mathematical objects which take a specific number of parameters. However the situation is more complex in the case of mathematical operators which take a variable, or arbitrary number of parameters, for example nary functions like plus which in OpenMath terminology is represented by the symbol: <OMS cd="arith3" name="plus"/> or a constructor of objects with no predetermined size, for example the basic vector constructor, in OpenMath this is represented by the symbol: <OMS cd="linalg2" name="vector"/>
Some attempt has been made to address this problem in the OMDoc
[5] specification with the introduction of the
presentation element. The style of the presentation may be
controlled via a number of attributes which control various aspects
of the presentation, e.g. the bracketing style, fixity etc. However
notations exist for which there is no obvious way to include the
relevant presentation markup in a
presentation element apart from including XSLT in an XML
CDATA section in the OMDoc. This is discouraged even in the OMDoc
specification, which recognizes that hand-coding XSLT is ``a tedious
and error-prone process''. An example of such a presentation is the
standard presentation for a simple continued fraction:
2 Specification Languages for classes of documents or textsA regular grammar allows specification of classes of sentences in a string. For example:
In a similar way XML Schema [6] allows specification of a class of objects in an XML document in an XML format. One may specify sequences of elements with particular types, containing children of particular types. It is also possible in XML Schema to restrict the names and values of attributes belonging to a specific element. Text content of an element may be restricted in an exact manner. The subset of the regular expression grammar that we are especially interested in when expressed in the XML Schema framework, is shown by the following example:2 <xsd:sequence minOccurs="1" maxOccurs="5"> <xsd:element name="mn" type="xsd:decimal"/> </xsd:sequence> This fragment would match a sequence of elements which
consisted of between 1 to 5 occurrences of the element
|
| as opposed to |
|
we would use the following markup:
<xm:apply> <xm:identity style="square[zero:italics;one:bold]"/> <cn> 3 </cn> </xm:apply>
The main theme of the paper [1] concerns the process of producing meta stylesheets to construct XSLT stylesheets [7] for converting documents written in an extended MathML into another form, for example presentation MathML. Now, one of the most difficult problems encountered in the construction of these meta stylesheets, is how to deal with the template functions. It is clear that for different template functions one may (not always, as certain mathematical objects are structurally similar with respect to their components, e.g. consider a vector and a list object) require different meta stylesheets in order to perform the desired translation. This could be seen as a never ending job if one is allowed total freedom in the OpenMath symbols used in the template functions (especially since OpenMath is an extensible markup mechanism). It is therefore necessary to specify a restricted vocabulary for use within the template functions. It may also occur that XSLT is ill-suited for performing some of the calculations implied by the template functions. We may use the XSLT document function, element in this case. One use of the document element would be to execute a Java method designed to perform the required calculation via a servlet. The Java method could take XML elements as its parameters and return XML as its return value, e.g. it might operate on an OpenMath expression and return a minimal form.
By the use of the extensions suggested in section 3 to the scheme suggested in [1] we may specify effective presentation/semantic mappings for mathematical objects which are not of a fixed size. With respect to a database of notation/content dictionary mappings written using this scheme, it will then be possible to specify mathematical notation which has an unambiguous meaning. We also suggest an effective markup which allows specification of different styles for implicit objects appearing at any level within a notation. With respect to implementing some conversions of this extended markup to some other form (for example, presentation MathML), we suggest the use of the XSLT document element, in conjunction with servlets to communicate with external processes for performing calculations which are ill-suited to XSLT.
3 We display a
notation element for the partialdiff symbol. The version of
the
notation used here is that which will display as
. Where the function f is differentiated with
respect to x and y. The order of the
differentiation is
and
with respect to x and y respectively and
.
<Notation>
<version precedence="100">
<image src="partialDiffDefault.gif"/>
<tex>
\frac{\partial^
...
</tex>
<math>
<mrow>
<mfrac>
<msup><mo>∂</mo><mi
xref="sum">n</mi></msup>
<mrow><msup>
<mrow><mo>∂</mo>
<mi xref="x">x</mi>
<mrow>
<msub
xref="n1"><mi>n</mi><mn>1</mn></msub></msup>
<mrow><mo>∂</mo>
<mi xref="y">y</mi>
<mrow>
<msub
xref="n2"><mi>n</mi><mn>2</mn></msub></msup>
</mrow>
</mfrac>
<mi>f</mi>
<mo>⁡</mo>
<mfenced>
<mi xref="x">x</mi>
<mi xref="y">y</mi>
</mfenced>
</mrow>
</math>
</version>
<semantic_template>
<OMOBJ> <!-- this OMOBJ is the prototype -->
<OMA><OMS cd="calculus2" name="partialdiff"/>
<OMA><OMS cd="list1" name="list"/>
<OMA><OMS cd="list1" name="list"/>
<OMI id='x'> 1 </OMI>
<OMV name="n1" id="n1"/>
</OMA>
<OMA><OMS cd="list1" name="list"/>
<OMI id='y'> 2 </OMI>
<OMV name="n2" id="n2"/>
</OMA>
</OMA>
<OMV name="f" id="functionName"/> <!-- this is the
function -->
</OMA>
</OMOBJ>
<!-- the following function specification calculates the sum of the the
two
orders located in the prototype -->
<OMBIND id="sum">
<OMS cd="fns1" name="lambda"/>
<OMBVAR>
</OMBVAR>
<OMA>
<OMS cd="arith3" name="plus"/>
<OMV name="n1" xref="n1"/>
<OMV name="n2" xref="n2"/>
</OMA>
</OMBIND>
</semantic_template>
</Notation>
Definition of some Non Standard Symbols
We give some definitions of symbols which have been used in the preceding, but which are not part of the standard OpenMath content dictionaries at present.