<semantics> - MathML 编辑

In MathML there are two ways to mark up mathematics: Presentation MathML is used to control the layout of equations, whereas Content MathML is designed to encode the semantic mathematical meaning and to make expressions understandable to computer algebra systems. The MathML elements <semantics>, <annotation> and <annotation-xml> are used to combine presentation and content markup and to provide both, layout information and semantic meaning of mathematical expressions.

The <semantics> element acts as a container element associating annotations and must have child elements (it will raise an invalid markup error otherwise). The <annotation> element is the container element containing semantic information in a non-XML format, whereas the <annotation-xml> element contains content in an XML format, e.g. Content MathML or OpenMath.

The rules of determining the visible child in a <semantics> element are the following:

  • If no rule other rule applies: By default only the first child is rendered, which is supposed to be presentation markup.
  • If the first child is a presentation MathML element other than <annotation> or <annotation-xml>, render the first child.
  • If no Presentation MathML is found, render the first <annotation> or <annotation-xml> child element of <semantics>.
    Beware that <annotation-xml> elements are only recognized, if the encoding attribute is set to one of the following:
    • "application/mathml-presentation+xml"
    • "MathML-Presentation"
    • "SVG1.1"
    • "text/html"
    • "image/svg+xml"
    • "application/xml".
    Note that "application/mathml+xml" is not mentioned here as it does not distinguish between Content or Presentation MathML.

Attributes

The following attributes can be set on <annotation> and <annotation-xml>:

definitionURL
The location of the annotation key symbol.
displaystyle
A Boolean value specifying whether more vertical space is used for displayed equations or, if set to false, a more compact layout is used to display formulas. The main effect is that larger versions of operators are displayed, when displaystyle is set to true. See also largeop and movablelimits on <mo>.
encoding
The encoding of the semantic information in the annotation (e.g. "MathML-Content", "MathML-Presentation", "application/openmath+xml", "image/png")
cd
The content dictionary that contains the annotation key symbol.
name
The name of the annotation key symbol.
src
The location of an external source for semantic information.

Example

<math>
  <semantics>

    <!-- Presentation MathML -->
    <mrow>
      <msup>
        <mi>x</mi>
        <mn>2</mn>
      </msup>
      <mo>+</mo>
      <mi>y</mi>
    </mrow>

    <!-- Content MathML -->
    <annotation-xml encoding="MathML-Content">
      <apply>
        <plus/>
        <apply>
          <power/>
          <ci>x</ci>
          <cn type="integer">2</cn>
        </apply>
        <ci>y</ci>
      </apply>
    </annotation-xml>

    <!-- annotate an image -->
    <annotation encoding="image/png" src="some/path/formula.png"/>

    <!-- annotate TeX -->
    <annotation encoding="application/x-tex">
      x^{2} + y
    </annotation>

  </semantics>
</math>

Specifications

SpecificationStatusComment
MathML Core
The definition of 'semantics' in that specification.
DraftDraft specification
MathML 3.0
The definition of 'Mixing Markup Languages for Mathematical Expressions' in that specification.
RecommendationCurrent specification
MathML 2.0
The definition of 'Combining Presentation and Content Markup ' in that specification.
RecommendationInitial specification

Browser compatibility

BCD tables only load in the browser

Gecko-specific notes

  • The algorithm of determining the visible child in <semantics> has been corrected in (Firefox 23 / Thunderbird 23 / SeaMonkey 2.20) to match the MathML specification. In prior versions the first child element has been rendered.
  • In Gecko <annotation> and <annotation-xml> elements are ignored if the src attribute is set.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:52 次

字数:6676

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文