3.3 MathML Attributes

 < Day Day Up > 



3.3 MathML Attributes

Each MathML element has a number of attributes. The attribute for an element is specified after the element name in the start tag of the element, using the syntax: attribute-name="value". The value of the attribute must be enclosed in either single quotation marks or double quotation marks. The following six attributes are accepted by all MathML elements:

  • class, style, and id: to facilitate use of CSS and XSL stylesheets

  • xlink:href: used for setting up links

  • xref: for use in parallel markup

  • other: used for specifying nonstandard attributes that are not defined in MathML but may be supported by specific processing applications

In addition, each content or presentation element may have other attributes based on its specific role. For example, the mfrac element has an attribute called linethickness, as shown here:

    <mrow>      <mo>(</mo>      <mfrac linethickness="0">        <mi>n</mi>        <mi>m</mi>      </mfrac>      <mo>)</mo>    </mrow> 

The linethickness attribute determines the thickness of the line that separates the numerator and denominator of the fraction. The default value of this attribute is 1, which corresponds to a line of normal thickness. In the above example, linethickness is set to 0, which corresponds to the line being invisible.

MathML attributes can be set in two ways:

  • They can be explicitly set in the start tag of an element, as in the above example.

  • They can take the default value if not specified explicitly. The default value can be specified in the DTD, or it can be automatic (specified by the MathML rendering software) or inherited (from the surrounding environment).

An example of an inherited value that overrides a default value is shown here:

x + y

    <math>      <mrow>        <mstyle mathsize="18 pt">          <mi>x</mi>          <mo>+</mo>        </mstyle>        <mi>y</mi>      </mrow>    </math> 

The example uses the presentation element mstyle, which you use to set style attributes for presentation markup. The value of all this element's attributes is automatically inherited by all its child elements. Here, the mi element containing the x and the mo element containing the + both inherit the value of the mathsize attribute, even though this attribute is not specified explicitly on either of the two elements.

MathML restricts the types of values certain attributes can take. These restrictions may be specified in the MathML DTD or may be additional rules that are enforced by MathML processors even if they are not explicitly described in the DTD. The allowed values for each type of attribute are described in the discussion of individual elements in Chapters 4 and 5. The following syntax is used to specify the possible values an attribute can take:

    attribute-name  value1 | value2 ... | valueN 

The allowed values are separated by a vertical bar indicating that any one of them can be used as a value for attribute-name. For example, the form attribute of the <mo> element can take three possible values:

    form   prefix|infix|postfix 

Certain attribute values may be indicated with a + (which means the value can occur 1 or more times) or with a * (which means the value can occur 0 or more times). Here is an example:

    columnalign (left|center|right)+ 

This means that the columnalign attribute of the mtable element can take a set of values, each controlling the alignment of a specific column of the table. If fewer values than the number of columns are specified, the last value is repeated as many times as necessary. If there are more values than the number of columns, the extra values are ignored.

The notation used to indicate allowed values of attributes in the MathML specification is summarized in Table 3.1. For compactness, the same notation is used later in the book when we describe the attributes in the discussion of individual elements.

Table 3.1: Notation Used to Indicate Allowed Values of MathML Attributes

Notation

Meaning

x | y

Either x or y is allowed.

x*

x can occur zero or more times.

x+

x can occur one or more times.

(x | y)+

Either x or y can occur one or more times.

[x]

x is optional.

h-unit

Unit of horizontal distance.

v-unit

Unit of vertical distance.

%

Percentage of the default value.

#rgb component.

Color in Red Green Blue (RGB) units with one digit for each color

#rrggbb

Color in RGB units with two digits for each color component.

Some attributes are specified with a unit in addition to a numerical value. In this case, the attribute value typically consists of a number followed by a unit. For example, the allowed values of the mathsize attribute are specified as:

    mathsize small|normal|big|number v-unit 

Here, v-unit denotes a unit of vertical length. The example below shows the use of an attribute value that includes a unit (it causes the identifier x to be displayed in a 24-point font size):

    <mi mathsize="24 pt">x</mi> 

Possible units and the identifiers used to denote units in attribute values are listed in Table 3.2.

Table 3.2: Possible Units and the Identifiers Used to Denote Units in Attribute Values

Identifier

Description

em

Width of the letter "m" in the font being used

ex

Height of the letter "x" in the font being used

px

Pixels

in

Inches

cm

Centimeters

mm

Millimeters

pt

Points

pc

Picas

%

Percentage

If an attribute values is specified as a percentage, it is usually a percentage of the default value of that attribute. For example:

    <mfrac linethickness="2"><mi>x</mi><mi>y</mi></mfrac> 

is equivalent to

    <mfrac linethickness="200 %"><mi>x</mi><mi>y</mi></mfrac>< 



 < 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