Name

math:math — Root element of the transformation.

Synopsis

<xsl:template match="math:math">
<xsl:param name="svgMasterUnit" select="$svgMasterUnit" tunnel="yes"/>
<xsl:param name="initSize" select="$initSize" tunnel="yes"/>
<xsl:param name="sizeMult" select="0.71" tunnel="yes"/>
<xsl:param name="minSize" select="$minSize" tunnel="yes"/>
<xsl:param name="svgBorder" select="$initSize div 5" tunnel="yes"/>
<xsl:param name="errorMargin" select="$initSize div 10" tunnel="yes"/>
<xsl:param name="rightSwitch" select="$initSize div 15" tunnel="yes"/>
<xsl:param name="numDenSpace" select="$initSize div 5" tunnel="yes"/>
<xsl:param name="overUnderSpace" select="$initSize div 10" tunnel="yes"/>
<xsl:param name="tableSpace" select="$initSize div 2" tunnel="yes"/>
<xsl:param name="fracWidMarg" select="$initSize div 15" tunnel="yes"/>
<xsl:param name="rtTopSpc" select="$initSize div 6" tunnel="yes"/>
<xsl:param name="rtFrnSpcFac" select="0.5" tunnel="yes"/>
<xsl:param name="fontName" select="$fontName" tunnel="yes"/>
<xsl:param name="scriptlevel" select="0" tunnel="yes"/>
<xsl:param name="displayStyle" select="'true'" tunnel="yes"/>
<xsl:param name="veryverythinmathspace" select="'0.055556em'" tunnel="yes"/>
<xsl:param name="verythinmathspace" select="'0.111111em'" tunnel="yes"/>
<xsl:param name="thinmathspace" select="'0.166667em'" tunnel="yes"/>
<xsl:param name="mediummathspace" select="'0.222222em'" tunnel="yes"/>
<xsl:param name="thickmathspace" select="'0.277778em'" tunnel="yes"/>
<xsl:param name="verythickmathspace" select="'0.333333em'" tunnel="yes"/>
<xsl:param name="veryverythickmathspace" select="'0.388889em'" tunnel="yes"/>
  ...
</xsl:template>

Description

The root element is the starting point of the transformation. This template is called when a math element is found in the document that is currently transformed. This template will call the two passes of the transformation. First, it will retrieve the annotated tree from the formatting mode by applying formatting mode template on the entire MathML tree. Then, it will retrieve the total width and height of the expression and writes the header of the SVG file. It will also write metadata information about the baseline. This information is used to shift the SVG picture when pMML2SVG is calling from an other stylesheet and when picture must be embedded into a text line. Finally, the root element will call the drawing mode on the annotated tree to draw all element on the canevas.

All elements follow the same scheme. In formatting mode, the font size is first computed, all attribute for the element are retrieved. After that, the children elements are computed if necessary, then the box is created by computing all its attribute and finally the tree node is annotated.

In drawing mode, the X and Y coordinates of the box is first computed. Then, the children are drawn if necessary (by calling their drawing mode) and, finally the elements of the box itself are added on the canvas (fraction bar, boxes, etc.).

The first element that is called in each transformation is the math element. This element is the root of each MathML equation.

Each template in the formatting mode must take at least three parameters:

X, Y

Represent the initial upper left corner of the box where the element will be drawn. If the baseline is not set, Y value is used to set a new baseline for the current element.

BASELINE

By default, this value is zero. It means that no baseline has been created and that the current element will decide where its baseline will be. In that case, the element will align its top edge on the initial Y value. If this parameter is set, the element has to be aligned on this baseline.

In the drawing mode, at least two paramaters are required:

xShift, yShift

These values determine if the element has to be shifted to be correctly displayed. For example, when rendering a fraction. Both numerator and denominator will be aligned on the baseline by the formatting mode. Therefore, numerator has to be shifted to the top and denominator to the bottom to find their final correct place. When drawing, numerator and denominator elements will receive shift values via these paramaters.

Parameters

Parameters can be retrieved through the tunnel: global parameters or style parameters. A tunnel is a way to forward parameters to all elements through the XML tree without sending them explicitly. It means that each template implicitly forwards these paramaters to all templates they call. Global parameters are set by default by the root template. All these values can be changed if the stylesheet is called via another stylesheet. Some of them can also be changed by setting parameters when executing the transformation with an XSLT processor. Here is a description of all global paramaters.

Description of global parameters

svgMasterUnit

Determines the default unit that will be used to render the SVG picture. The default unit is pixel (px).

initSize

Determines the initial font size. This value cannot be changed by any MathML element. It can only be configured by setting it with the XSLT processor. This value can also be set by an external stylesheet that calls a MathML to SVG transformation. For example, the stylesheet that transforms the equation into picture in the XSL-FO code will set this value with respect to the current context. By default, the value of this parameter is 50.

sizeMult

sizeMult is a factor by which the font size has to be multiplied to render script element. This parameter works with scriptLevel. For example, if the script level is 5, you have to multiply the initial font size by sizeMult 5 times. This parameter can be set by a mstyle element. The default size multiplier is 0.71.

scriptlevel

Determines the number of times you will have to multiply the initial font size by sizeMult to render the current element. This parameter can be set by a mstyle element. The default script level is 0.

displayStyle

Determines the display scheme on some elements, for example, if display style is false, mover, munder and munderover limit of summation or integral operators will be moved from top and bottom to right. This parameter can be set by a mstyle element. The default script level is true.

minSize

Determines the minimal font size. This parameter can be set by a mstyle element but it is not yet supported. By default, this value is 8.

svgBorder

Determines the size of the transparent border that surrounds the picture. By default, this value depends on initSize and is initSize div 5. This value will also set the initial X and Y coordinates to launch the transformation.

rightSwitch

Determines the size of the space between a base and its subscript or superscript. This parameter is used in msub, msup and msubsup elements. By default, this value depends on initSize and is initSize div 15.

numDenSpace

Determines the space between the numerator and the denominator. This parameter is used in mfrac element. By default, this value depends on initSize and is initSize div 5.

overUnderSpace

Determines the size of the space between a base and its overscript or underscript. This parameter is used in munder, mover and munderover elements. By default, this value depends on initSize and is initSize div 10.

tableSpace

Determines the size of the space between two cells of a table. This parameter is used in mtable, mtd and mtr elements. By default, this value depends on initSize and is initSize div 2.

fracWidMarg

Determines the size of the fraction bar that outpasses the numerator or the denominator. This parameter is used in mfrac element. By default, this value depends on initSize and is initSize div 15.

rtTopSpc

Determines the size of the space over the base of a root to render the radical line. This parameter is used in msqrt and mroot elements. By default, this value depends on initSize and is initSize div 6.

rtFrnSpcFac

Determines the size of the space before the base of a root to render the radical line. By default this value is 0.5.

fontName

Determines the fonts that will be used to render elements. This parameter is a list of fonts separated by a comma. By default, the font list is STIXGeneral,STIXSize1. The way you can change this parameter is explained in the user guide.

Math space parameters

These parameters are used to determine the value of a space literal. The space literal can be used when a MathML attribute requires a horizontal measure. The default value for these parameters comes from the MathML specification. These values can be changed with the mstyle element.

Style tunnel parameters are used to implement the heritage of style. Currently, only mathvariant, mathcolor and mathbackground are implemented. Other style attributes are easy to add following the current scheme.

Description of each style paramaters

mathvariant

This attribute is partially supported and enables users to put the style in bold, italic or both. It also enables to change the font used to render an element. This last functionnality is not yet supported.

mathcolor

Enables users to change the color of an element. This attribute is fully supported.

mathbackground

Enables users to change the background color of an element. Currently, this attribute does nothing because SVG element does not have background to color. To fully implement this attribute, we have to draw a colored rectangle that has the size of the element.

All these tunnel parameters are forwarded to both formatting and drawing mode. They are available everywhere and can be modified by all elements. However, this modification is only reflected on the children, it is a good way to implement the inherited style attributes.