This repository has been archived by the owner on Jan 3, 2020. It is now read-only.
forked from w3c/mathml.old
-
Notifications
You must be signed in to change notification settings - Fork 0
/
chapter5.xml
1513 lines (1433 loc) · 77.9 KB
/
chapter5.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE html
SYSTEM "mathml.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
<title>Mixing Markup Languages for Mathematical Expressions</title>
<meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport" />
<style type="text/css">
/** Table of Contents taken from html 5.2 spec
stop flicker in toc **/
.toc a {
/* More spacing; use padding to make it part of the click target. */
padding-top: 0.1rem;
/* Larger, more consistently-sized click target */
display: block;
/* Reverse color scheme */
color: black;
border-color: #3980B5;
border-bottom-width: 3px !important;
margin-bottom: 0px !important;
}
.egmeta {
color:#5555AA;font-style:italic;font-family:serif;font-weight:bold;
}
div.graphic{margin-left:2em}
table.syntax {
font-size: 75%;
background-color: #DDDDDD;
border: thin solid;
}
table.syntax td {
border: solid thin;
}
table.syntax th {
text-align: left;
}
table.attributes td { padding-left:0.5em; padding-right:0.5em; border: solid thin; }
table.attributes td.attname { white-space:nowrap; vertical-align:top;}
table.attributes td.attdesc { background-color:#F0F0FF; padding-left:2em; padding-right:2em}
th.uname {font-size: 50%; text-align:left;}
code { font-family: monospace; }
div.constraint,
div.issue,
div.note,
div.notice { margin-left: 2em; }
li p { margin-top: 0.3em;
margin-bottom: 0.3em; }
div.exampleInner pre { margin-left: 1em;
margin-top: 0em; margin-bottom: 0em}
div.exampleOuter {border: 4px double gray;
margin: 0em; padding: 0em}
div.exampleInner { background-color: #d5dee3;
border-top-width: 4px;
border-top-style: double;
border-top-color: #d3d3d3;
border-bottom-width: 4px;
border-bottom-style: double;
border-bottom-color: #d3d3d3;
padding: 4px; margin: 0em }
div.exampleWrapper { margin: 4px }
div.exampleHeader { font-weight: bold;
margin: 4px}
a.mainindex {font-weight: bold;}
li.sitem {list-style-type: none;}
.error { color: red }
div.mathml-example {border:solid thin black;
padding: 0.5em;
margin: 0.5em 0 0.5em 0;
}
div.strict-mathml-example {border:solid thin black;
padding: 0.5em;
margin: 0.5em 0 0.5em 0;
}
div.strict-mathml-example h5 {
margin-top: -0.3em;
margin-bottom: -0.5em;}
var.meta {background-color:green}
var.transmeta {background-color:red}
pre.mathml {padding: 0.5em;
background-color: #FFFFDD;}
pre.mathml-fragment {padding: 0.5em;
background-color: #FFFFDD;}
pre.strict-mathml {padding: 0.5em;
background-color: #FFFFDD;}
span.uname {color:#999900;font-size:75%;font-family:sans-serif;}
.minitoc { border-style: solid;
border-color: #0050B2;
border-width: 1px ;
padding: 0.3em;}
.attention { border-style: solid;
border-width: 1px ;
color: #5D0091;
background: #F9F5DE;
border-color: red;
margin-left: 1em;
margin-right: 1em;
margin-top: 0.25em;
margin-bottom: 0.25em; }
.attribute-Name { background: #F9F5C0; }
.method-Name { background: #C0C0F9; }
.IDL-definition { border-style: solid;
border-width: 1px ;
color: #001000;
background: #E0FFE0;
border-color: #206020;
margin-left: 1em;
margin-right: 1em;
margin-top: 0.25em;
margin-bottom: 0.25em; }
.baseline {vertical-align: baseline}
#eqnoc1 {width: 10%}
#eqnoc2 {width: 80%; text-align: center; }
#eqnoc3 {width: 10%; text-align: right; }
div.div1 {margin-bottom: 1em;}
.h3style {
text-align: left;
font-family: sans-serif;
font-weight: normal;
color: #0050B2;
font-size: 125%;
}
h4 { text-align: left;
font-family: sans-serif;
font-weight: normal;
color: #0050B2; }
h5 { text-align: left;
font-family: sans-serif;
font-weight: bold;
color: #0050B2; }
th {background: #E0FFE0;}
p, blockquote, h4 { font-family: sans-serif; }
dt, dd, dl, ul, li { font-family: sans-serif; }
pre, code { font-family: monospace }
a.termref {
text-decoration: none;
color: black;
}
.mathml-render {
font-family: serif;
font-size: 130%;
border: solid 4px green;
padding-left: 1em;
padding-right: 1em;
}
</style>
<link rel="stylesheet" type="text/css" href="https://www.w3.org/StyleSheets/TR/2016/W3C-ED.css" /><script src="//www.w3.org/scripts/TR/2016/fixup.js"> </script></head>
<body>
<h1><a id="mixing"></a>5 Mixing Markup Languages for Mathematical Expressions</h1>
<!-- TOP NAVIGATION BAR -->
<nav id="toc">
<ol class="toc">
<li><a href="Overview.xml"><span class="secno"></span> Mathematical Markup Language (MathML) Version 4.0</a></li>
<li><a href="chapter4.xml"><span class="secno">4 </span> Content Markup</a></li>
<li><a href="chapter6.xml"><span class="secno">6 </span> Interactions with the Host Environment</a></li>
<li><a href="chapter5.xml"><span class="secno">5 </span> Mixing Markup Languages for Mathematical Expressions</a>
<ol class="toc">
<li><a href="chapter5.xml#mixing.semantic.annotations"><span class="secno">5.1 </span> Annotation Framework</a>
<ol class="toc">
<li><a href="chapter5.xml#mixing.annotation.elements"><span class="secno">5.1.1 </span> Annotation elements</a>
</li>
<li><a href="chapter5.xml#mixing.annotation.keys"><span class="secno">5.1.2 </span> Annotation keys</a>
</li>
<li><a href="chapter5.xml#mixing.alternate.representations"><span class="secno">5.1.3 </span> Alternate representations</a>
</li>
<li><a href="chapter5.xml#mixing.content.equiv"><span class="secno">5.1.4 </span> Content equivalents</a>
</li>
<li><a href="chapter5.xml#mixing.annotation.references"><span class="secno">5.1.5 </span> Annotation references</a>
</li>
</ol>
</li>
<li><a href="chapter5.xml#mixing.semantic.elements"><span class="secno">5.2 </span> Elements for Semantic Annotations</a>
<ol class="toc">
<li><a href="chapter5.xml#mixing.elements.semantics"><span class="secno">5.2.1 </span> The <code><semantics></code> element</a>
<ol class="toc">
<li><a href="chapter5.xml#id.5.2.1.1"><span class="secno">5.2.1.1 </span> Description</a>
</li>
<li><a href="chapter5.xml#id.5.2.1.2"><span class="secno">5.2.1.2 </span> Attributes</a>
</li>
</ol>
</li>
<li><a href="chapter5.xml#mixing.elements.annotation"><span class="secno">5.2.2 </span> The <code><annotation></code> element</a>
<ol class="toc">
<li><a href="chapter5.xml#id.5.2.2.1"><span class="secno">5.2.2.1 </span> Description</a>
</li>
<li><a href="chapter5.xml#id.5.2.2.2"><span class="secno">5.2.2.2 </span> Attributes</a>
</li>
</ol>
</li>
<li><a href="chapter5.xml#mixing.elements.annotation.xml"><span class="secno">5.2.3 </span> The <code><annotation-xml></code> element</a>
<ol class="toc">
<li><a href="chapter5.xml#id.5.2.3.1"><span class="secno">5.2.3.1 </span> Description</a>
</li>
<li><a href="chapter5.xml#id.5.2.3.2"><span class="secno">5.2.3.2 </span> Attributes</a>
</li>
<li><a href="chapter5.xml#html.annotation.xml"><span class="secno">5.2.3.3 </span> Using <code>annotation-xml</code> in HTML documents</a>
</li>
</ol>
</li>
</ol>
</li>
<li><a href="chapter5.xml#mixing.markup"><span class="secno">5.3 </span> Combining Presentation and Content Markup</a>
<ol class="toc">
<li><a href="chapter5.xml#mixing.pmincm"><span class="secno">5.3.1 </span> Presentation Markup in Content Markup</a>
</li>
<li><a href="chapter5.xml#mixing.cminpm"><span class="secno">5.3.2 </span> Content Markup in Presentation Markup</a>
</li>
</ol>
</li>
<li><a href="chapter5.xml#mixing.parallel"><span class="secno">5.4 </span> Parallel Markup</a>
<ol class="toc">
<li><a href="chapter5.xml#mixing.top.level"><span class="secno">5.4.1 </span> Top-level Parallel Markup</a>
</li>
<li><a href="chapter5.xml#mixing.cr"><span class="secno">5.4.2 </span> Parallel Markup via Cross-References</a>
</li>
</ol>
</li>
</ol>
</li>
</ol>
</nav>
<div class="div1">
<p>MathML markup can be combined with other markup languages, and
these mixing constructions are realized by the semantic annotation
elements. The semantic annotation elements provide an important tool
for making associations between alternate representations of an
expression, and for associating semantic properties and other
attributions with a MathML expression. These elements allow
presentation markup and content markup to be combined in several
different ways. One method, known as <em>mixed markup</em>, is to
intersperse content and presentation elements in what is essentially a
single tree. Another method, known as <em>parallel markup</em>,
is to provide both explicit presentation markup and content markup in
a pair of markup expressions, combined by a single <code>semantics</code>
element.
</p>
<div class="div2">
<h2><a id="mixing.semantic.annotations"></a>5.1 Annotation Framework</h2>
<p>
An important concern of MathML is to represent associations between
presentation and content markup forms for an expression. Representing
associations between MathML expressions and data of other kinds is
also important in many contexts. For this reason, MathML provides a
general framework for annotation. A MathML expression may be
decorated with a sequence of pairs made up of a symbol that indicates
the kind of annotation, known as the <em>annotation key</em>, and
associated data, known as the <em>annotation value</em>.
</p>
<div class="div3">
<h3><a id="mixing.annotation.elements"></a>5.1.1 Annotation elements</h3>
<p>
The <code>semantics</code>, <code>annotation</code>, and
<code>annotation-xml</code> elements are used together to represent
annotations in MathML. The <code>semantics</code> element provides the
container for a expression and its annotations. The
<code>annotation</code> element is the container for text
annotations, and the <code>annotation-xml</code> element is used for
structured
annotations. The <code>semantics</code> element contains the expression
being annotated as its first child, followed by a sequence of zero or
more <code>annotation</code> and/or <code>annotation-xml</code> elements.
</p>
<table>
<tr>
<td>
<pre class="mathml"><semantics>
<mrow>
<mrow>
<mi>sin</mi>
<mo><span title="ApplyFunction">&#x2061;</span><span class="uname"><!--function application--></span></mo>
<mfenced><mi>x</mi></mfenced>
</mrow>
<mo>+</mo>
<mn>5</mn>
</mrow>
<annotation encoding="application/x-tex">
\sin x + 5
</annotation>
<annotation-xml encoding="application/openmath+xml">
<OMA xmlns="http://www.openmath.org/OpenMath">
<OMS cd="arith1" name="plus"/>
<OMA><OMS cd="transc1" name="sin"/><OMV name="x"/></OMA>
<OMI>5</OMI>
</OMA>
</annotation-xml>
</semantics></pre>
</td>
<td class="mathml-render" valign="middle"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics>
<mrow>
<mrow>
<mi>sin</mi>
<mo>⁡</mo>
<mfenced><mi>x</mi></mfenced>
</mrow>
<mo>+</mo>
<mn>5</mn>
</mrow>
<annotation encoding="application/x-tex">
\sin x + 5
</annotation>
<annotation-xml encoding="application/openmath+xml">
<OMA xmlns="http://www.openmath.org/OpenMath">
<OMS cd="arith1" name="plus"/>
<OMA><OMS cd="transc1" name="sin"/><OMV name="x"/></OMA>
<OMI>5</OMI>
</OMA>
</annotation-xml>
</semantics></math></td>
</tr>
</table>
<p id="html-xml1">Note that this example makes use of the namespace extensibility
that is only available in the XML syntax of MathML. If this example is included in
an HTML document
then it would be considered <em>invalid</em> and the OpenMath elements would be parsed as
elements in the MathML namespace. See <a href="#html.annotation.xml">Section 5.2.3.3 Using <code>annotation-xml</code> in HTML documents</a> for details.</p>
<p>The <code>semantics</code> element is considered to be both a presentation
element and a content element, and may be used in either context.
All MathML processors should process the <code>semantics</code> element,
even if they only process one of these two subsets of MathML.
</p>
</div>
<div class="div3">
<h3><a id="mixing.annotation.keys"></a>5.1.2 Annotation keys</h3>
<p>An <em>annotation key</em> specifies the relationship between an
expression and an annotation. Many kinds of relationships are possible.
Examples include alternate representations, specification or clarification
of semantics, type information, rendering hints, and private data
intended for specific processors. The annotation key is the primary
means by which a processor determines whether or not to process an
annotation.</p>
<p>The logical relationship between an expression and an annotation
can have a significant impact on the proper processing of the
expression. For example, a particular annotation form, called <em>semantic
attributions</em>, cannot be ignored without altering the meaning
of the annotated expression, at
least in some processing contexts. On the other hand, alternate
representations do not alter the meaning of an expression, but may
alter the presentation of the expression as they are frequently used
to provide rendering hints. Still other annotations carry private data or
metadata that are useful in a specific context, but do not alter either
the semantics or the presentation of the expression.</p>
<p>In MathML 3, annotation keys are defined as symbols in <a href="chapter4.xml#contm.cds">Content Dictionaries</a>, and are specified using
the <code>cd</code> and <code>name</code> attributes on the
<code>annotation</code> and <code>annotation-xml</code> elements. For backward
compatibility with MathML 2, an annotation key may also be referenced
using the <code>definitionURL</code> attribute as an alternative to the
<code>cd</code> and <code>name</code> attributes. Further details on
referencing symbols in Content Dictionaries are discussed in <a href="chapter4.xml#contm.csymbol">Section 4.2.3 Content Symbols <code><csymbol></code></a>. The symbol definition in a Content Dictionary
for an annotation key may have a <code>role</code> property. Two
particular roles are relevant for annotations: a role of
"attribution" identifies a generic annotation that can
be ignored without altering the meaning of the annotated term, and a
role of "semantic-attribution" indicates that the annotation
is a semantic annotation, that is, the annotation cannot be ignored
without potentially altering the meaning of the expression.
</p>
<p>MathML 3 provides two predefined annotation keys for the most common
kinds of annotations: <a href="http://www.openmath.org/cd/mathmlkeys.xhtml#alternate-representation">alternate-representation</a> and <a href="http://www.openmath.org/cd/mathmlkeys.xhtml#contentequiv">contentequiv</a> defined in the <a href="http://www.openmath.org/cd/mathmlkeys.xhtml">mathmlkeys</a> content
dictionary. The <a href="http://www.openmath.org/cd/mathmlkeys.xhtml#alternate-representation">alternate-representation</a> annotation key specifies that the
annotation value provides an alternate representation for an
expression in some other markup language, and the <a href="http://www.openmath.org/cd/mathmlkeys.xhtml#contentequiv">contentequiv</a> annotation key specifies that
the annotation value provides a semantically equivalent alternative
for the annotated expression. Further details about the use of
these keys is given in the sections below.</p>
<p>The default annotation key is <a href="http://www.openmath.org/cd/mathmlkeys.xhtml#alternate-representation">alternate-representation</a> when no annotation key is
explicitly specified on an <code>annotation</code> or
<code>annotation-xml</code> element.</p>
<p>Typically, annotation keys specify only the logical nature of the
relationship between an expression and an annotation. The data format
for an annotation is indicated with the <code>encoding</code>
attribute. In MathML 2, the <code>encoding</code> attribute was the
primary information that a processor could use to determine whether or
not it could understand an annotation. For backward compatibility,
processors are encouraged to examine both the annotation key and
<code>encoding</code> attribute. In
particular, MathML 2 specified the predefined encoding values
<code>MathML</code>, <code>MathML-Content</code>, and
<code>MathML-Presentation</code>. The <code>MathML</code> encoding
value is used to indicate an <code>annotation-xml</code> element contains
a MathML expression. The use of the other values is more specific, as
discussed in following sections.</p>
<p>While the predefined <a href="http://www.openmath.org/cd/mathmlkeys.xhtml#alternate-representation">alternate-representation</a> and <a href="http://www.openmath.org/cd/mathmlkeys.xhtml#contentequiv">contentequiv</a> keys cover many common use cases, user
communities are encouraged to define and standardize additional
content dictionaries as necessary. Annotation keys in user-defined,
public Content Dictionaries are preferred over private encoding
attribute value conventions, since content dictionaries are more
expressive, more open and more maintainable than private encoding
values. However, for backward compatibility with MathML 2, the
encoding attribute may also be used.
</p>
</div>
<div class="div3">
<h3><a id="mixing.alternate.representations"></a>5.1.3 Alternate representations</h3>
<p>Alternate representation annotations are most often used to
provide renderings for an expression, or to provide an equivalent
representation in another markup language. In general, alternate
representation annotations do not alter the meaning of the annotated
expression, but may alter its presentation.</p>
<p>A particularly important case is the use of a presentation MathML
expression to indicate a preferred rendering for a content MathML
expression. This case may be represented by labeling the annotation
with the <code>application/mathml-presentation+xml</code> value for
the <code>encoding</code> attribute. For backward compatibility with
MathML 2.0, this case can also be represented with the equivalent
<code>MathML-Presentation</code> value for the <code>encoding</code>
attribute. Note that when a presentation MathML annotation is
present in a <code>semantics</code> element, it may be used as the
default rendering of the <code>semantics</code> element, instead of
the default rendering of the first child.
</p>
<p>In the example below, the <code>semantics</code> element binds together
various alternate representations for a content MathML expression.
The presentation MathML annotation may be used as the
default rendering, while the other annotations give representations
in other markup languages. Since no attribution keys are explicitly
specified, the default annotation key
<a href="http://www.openmath.org/cd/mathmlkeys.xhtml#alternate-representation">alternate-representation</a> applies
to each of the annotations.
</p>
<table>
<tr>
<td>
<pre class="mathml">
<semantics>
<apply>
<plus/>
<apply><sin/><ci>x</ci></apply>
<cn>5</cn>
</apply>
<annotation-xml encoding="MathML-Presentation">
<mrow>
<mrow>
<mi>sin</mi>
<mo><span title="ApplyFunction">&#x2061;</span><span class="uname"><!--function application--></span></mo>
<mfenced open="(" close=")"><mi>x</mi></mfenced>
</mrow>
<mo>+</mo>
<mn>5</mn>
</mrow>
</annotation-xml>
<annotation encoding="application/x-maple">
sin(x) + 5
</annotation>
<annotation encoding="application/vnd.wolfram.mathematica">
Sin[x] + 5
</annotation>
<annotation encoding="application/x-tex">
\sin x + 5
</annotation>
<annotation-xml encoding="application/openmath+xml">
<OMA xmlns="http://www.openmath.org/OpenMath">
<OMA>
<OMS cd="arith1" name="plus"/>
<OMA><OMS cd="transc1" name="sin"/><OMV name="x"/></OMA>
<OMI>5</OMI>
</OMA>
</OMA>
</annotation-xml>
</semantics></pre>
</td>
<td class="mathml-render" valign="middle"><math xmlns="http://www.w3.org/1998/Math/MathML">
<semantics>
<apply>
<plus/>
<apply><sin/><ci>x</ci></apply>
<cn>5</cn>
</apply>
<annotation-xml encoding="MathML-Presentation">
<mrow>
<mrow>
<mi>sin</mi>
<mo>⁡</mo>
<mfenced open="(" close=")"><mi>x</mi></mfenced>
</mrow>
<mo>+</mo>
<mn>5</mn>
</mrow>
</annotation-xml>
<annotation encoding="application/x-maple">
sin(x) + 5
</annotation>
<annotation encoding="application/vnd.wolfram.mathematica">
Sin[x] + 5
</annotation>
<annotation encoding="application/x-tex">
\sin x + 5
</annotation>
<annotation-xml encoding="application/openmath+xml">
<OMA xmlns="http://www.openmath.org/OpenMath">
<OMA>
<OMS cd="arith1" name="plus"/>
<OMA><OMS cd="transc1" name="sin"/><OMV name="x"/></OMA>
<OMI>5</OMI>
</OMA>
</OMA>
</annotation-xml>
</semantics></math></td>
</tr>
</table>
<p id="html-xml2">Note that this example makes use of the namespace extensibility
that is only available in the XML syntax of MathML. If this example is included in
an HTML document
then it would be considered <em>invalid</em> and the OpenMath elements would be parsed as
elements un the MathML namespace. See <a href="#html.annotation.xml">Section 5.2.3.3 Using <code>annotation-xml</code> in HTML documents</a> for details.</p>
</div>
<div class="div3">
<h3><a id="mixing.content.equiv"></a>5.1.4 Content equivalents</h3>
<p>Content equivalent annotations provide additional computational
information about an expression. Annotations with the
<a href="http://www.openmath.org/cd/mathmlkeys.xhtml#contentequiv">contentequiv</a> key cannot be ignored
without potentially changing the behavior of an expression.</p>
<p>An important case arises when a content MathML annotation is used
to disambiguate the meaning of a presentation MathML expression.
This case may be represented by labeling the annotation with the
<code>application/mathml-content+xml</code> value for the
<code>encoding</code> attribute. In
MathML 2, this type of annotation was represented with the equivalent
<code>MathML-Content</code> value for the <code>encoding</code> attribute,
so processors are urged to support this usage for backward compatibility.
A content MathML annotation, whether in MathML 2 or 3, may be used for
other purposes as well, such as for other kinds of semantic assertions.
Consequently, in MathML 3, the
<a href="http://www.openmath.org/cd/mathmlkeys.xhtml#contentequiv">contentequiv</a> annotation key should
be used to make an explicit assertion that the annotation provides a
definitive content markup equivalent for an expression.</p>
<p>In the example below, an ambiguous presentation MathML expression
is annotated with a <code>MathML-Content</code> annotation clarifying
its precise meaning.</p>
<table>
<tr>
<td>
<pre class="mathml">
<semantics>
<mrow>
<mrow>
<mi>a</mi>
<mfenced open="(" close=")">
<mrow><mi>x</mi><mo>+</mo><mn>5</mn></mrow>
</mfenced>
</mrow>
</mrow>
<annotation-xml cd="mathmlkeys" name="contentequiv"
encoding="MathML-Content">
<apply>
<ci>a</ci>
<apply><plus/><ci>x</ci><cn>5</cn></apply>
</apply>
</annotation-xml>
</semantics></pre>
</td>
<td class="mathml-render" valign="middle"><math xmlns="http://www.w3.org/1998/Math/MathML">
<semantics>
<mrow>
<mrow>
<mi>a</mi>
<mfenced open="(" close=")">
<mrow><mi>x</mi><mo>+</mo><mn>5</mn></mrow>
</mfenced>
</mrow>
</mrow>
<annotation-xml cd="mathmlkeys" name="contentequiv"
encoding="MathML-Content">
<apply>
<ci>a</ci>
<apply><plus/><ci>x</ci><cn>5</cn></apply>
</apply>
</annotation-xml>
</semantics></math></td>
</tr>
</table>
</div>
<div class="div3">
<h3><a id="mixing.annotation.references"></a>5.1.5 Annotation references</h3>
<p>In the usual case, each annotation element includes either character data
content (in the case of <code>annotation</code>) or XML markup data (in the case
of <code>annotation-xml</code>) that represents the <em>annotation value</em>.
There is no restriction on the type of annotation that may appear within a
<code>semantics</code> element. For example, an annotation could provide a
T<span style="vertical-align:-.4ex; margin-left:-.15ex; margin-right:-.15ex">E</span>X encoding, a linear input form for a computer algebra system,
a rendered image, or detailed mathematical type information.</p>
<p>In some cases the alternative children of a <code>semantics</code> element
are not an essential part of the behavior of the annotated expression, but
may be useful to specialized processors. To enable the availability of
several annotation formats in a more efficient manner, a <code>semantics</code>
element may contain empty <code>annotation</code> and <code>annotation-xml</code>
elements that provide <code>encoding</code> and <code>src</code> attributes
to specify an external location for the annotation value associated with
the annotation. This type of annotation is known as an <em>annotation
reference</em>.</p>
<pre class="mathml-fragment">
<semantics>
<mfrac><mi>a</mi><mrow><mi>a</mi><mo>+</mo><mi>b</mi></mrow></mfrac>
<annotation encoding="image/png" src="333/formula56.png"/>
<annotation encoding="application/x-maple" src="333/formula56.ms"/>
</semantics></pre>
<p>Processing agents that anticipate that consumers of exported markup may
not be able to retrieve the external entity referenced by such annotations
should request the content of the external entity at the indicated location
and replace the annotation with its expanded form.</p>
<p>An annotation reference follows the same rules as for other annotations
to determine the annotation key that specifies the relationship between
the annotated object and the annotation value.</p>
</div>
</div>
<div class="div2">
<h2><a id="mixing.semantic.elements"></a>5.2 Elements for Semantic Annotations</h2>
<p>This section explains the semantic mapping elements <code>semantics</code>,
<code>annotation</code>, and <code>annotation-xml</code>. These elements associate
alternate representations for a presentation or content expression, or
associate semantic or other attributions that may modify the meaning of
the annotated expression.</p>
<div class="div3">
<h3><a id="mixing.elements.semantics"></a>5.2.1 The <code><semantics></code> element</h3>
<div class="div4">
<h4><a id="id.5.2.1.1"></a>5.2.1.1 Description</h4>
<p>The <code>semantics</code> element is the container element that
associates annotations with a MathML expression. The
<code>semantics</code> element has as its first child the expression to be
annotated. Any MathML expression may appear as the first child of the
<code>semantics</code> element. Subsequent <code>annotation</code> and
<code>annotation-xml</code> children enclose the annotations.
An annotation represented in XML is enclosed in an
<code>annotation-xml</code> element. An annotation represented
in character data is enclosed in an <code>annotation</code> element.</p>
<p>As noted above, the <code>semantics</code> element is considered to be
both a presentation element and a content element, since it can act
as either, depending on its content. Consequently, all MathML
processors should process the <code>semantics</code> element, even if they
process only presentation markup or only content markup.
</p>
<p>The default rendering of a <code>semantics</code> element is the default
rendering of its first child. A renderer may use the information contained
in the annotations to customize its rendering of the annotated element.</p>
<table>
<tr>
<td>
<pre class="mathml"><semantics>
<mrow>
<mrow>
<mi>sin</mi>
<mo><span title="ApplyFunction">&#x2061;</span><span class="uname"><!--function application--></span></mo>
<mfenced><mi>x</mi></mfenced>
</mrow>
<mo>+</mo>
<mn>5</mn>
</mrow>
<annotation-xml cd="mathmlkeys" name="contentequiv" encoding="MathML-Content">
<apply>
<plus/>
<apply><sin/><ci>x</ci></apply>
<cn>5</cn>
</apply>
</annotation-xml>
<annotation encoding="application/x-tex">
\sin x + 5
</annotation>
</semantics></pre>
</td>
<td class="mathml-render" valign="middle"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics>
<mrow>
<mrow>
<mi>sin</mi>
<mo>⁡</mo>
<mfenced><mi>x</mi></mfenced>
</mrow>
<mo>+</mo>
<mn>5</mn>
</mrow>
<annotation-xml cd="mathmlkeys" name="contentequiv" encoding="MathML-Content">
<apply>
<plus/>
<apply><sin/><ci>x</ci></apply>
<cn>5</cn>
</apply>
</annotation-xml>
<annotation encoding="application/x-tex">
\sin x + 5
</annotation>
</semantics></math></td>
</tr>
</table>
</div>
<div class="div4">
<h4><a id="id.5.2.1.2"></a>5.2.1.2 Attributes</h4>
<table class="attributes">
<thead>
<tr>
<th>Name</th>
<th>values</th>
<th>default</th>
</tr>
</thead>
<tbody>
<tr>
<td rowspan="2" class="attname">definitionURL</td>
<td><a href="chapter2.xml#type.uri"><em>URI</em></a></td>
<td><em>none</em></td>
</tr>
<tr>
<td colspan="2" class="attdesc">The location of an external source for semantic information</td>
</tr>
<tr>
<td rowspan="2" class="attname">encoding</td>
<td><a href="chapter2.xml#type.string"><em>string</em></a></td>
<td><em>none</em></td>
</tr>
<tr>
<td colspan="2" class="attdesc">The encoding of the external semantic information</td>
</tr>
</tbody>
</table>
<p>The <code>semantics</code> element takes the <code>definitionURL</code> and
<code>encoding</code> attributes, which reference an external source for some
or all of the semantic information for the annotated element, as modified
by the annotation. The use of these attributes on the <code>semantics</code>
element is deprecated in MathML3.
</p>
</div>
</div>
<div class="div3">
<h3><a id="mixing.elements.annotation"></a>5.2.2 The <code><annotation></code> element</h3>
<div class="div4">
<h4><a id="id.5.2.2.1"></a>5.2.2.1 Description</h4>
<p>The <code>annotation</code> element is the container element for a semantic
annotation whose representation is parsed character data in a non-XML
format. The <code>annotation</code> element should contain the character
data for the annotation, and should not contain XML markup elements.
If the annotation contains one of the XML reserved characters
<code>&</code>, <code><</code> then these characters must
be encoded using an entity reference or
(in the XML syntax)
an XML <code>CDATA</code> section.</p>
</div>
<div class="div4">
<h4><a id="id.5.2.2.2"></a>5.2.2.2 Attributes</h4>
<table class="attributes">
<thead>
<tr>
<th>Name</th>
<th>values</th>
<th>default</th>
</tr>
</thead>
<tbody>
<tr>
<td rowspan="2" class="attname">definitionURL</td>
<td><a href="chapter2.xml#type.uri"><em>URI</em></a></td>
<td><em>none</em></td>
</tr>
<tr>
<td colspan="2" class="attdesc">The location of the annotation key symbol</td>
</tr>
<tr>
<td rowspan="2" class="attname">encoding</td>
<td><a href="chapter2.xml#type.string"><em>string</em></a></td>
<td><em>none</em></td>
</tr>
<tr>
<td colspan="2" class="attdesc">The encoding of the semantic information in the annotation</td>
</tr>
<tr>
<td rowspan="2" class="attname">cd</td>
<td><a href="chapter2.xml#type.string"><em>string</em></a></td>
<td>mathmlkeys</td>
</tr>
<tr>
<td colspan="2" class="attdesc">The content dictionary that contains the annotation key symbol</td>
</tr>
<tr>
<td rowspan="2" class="attname">name</td>
<td><a href="chapter2.xml#type.string"><em>string</em></a></td>
<td>alternate-representation</td>
</tr>
<tr>
<td colspan="2" class="attdesc">The name of the annotation key symbol</td>
</tr>
<tr>
<td rowspan="2" class="attname">src</td>
<td><a href="chapter2.xml#type.uri"><em>URI</em></a></td>
<td><em>none</em></td>
</tr>
<tr>
<td colspan="2" class="attdesc">The location of an external source for semantic information</td>
</tr>
</tbody>
</table>
<p>Taken together, the <code>cd</code> and <code>name</code> attributes
specify the annotation key symbol, which identifies the relationship
between the annotated element and the annotation, as described in
<a href="#mixing.annotation.elements">Section 5.1.1 Annotation elements</a>. The <code>definitionURL</code>
attribute provides an alternate way to reference the annotation key
symbol as a single attribute. If none of these attributes are present,
the annotation key symbol is the symbol
<a href="http://www.openmath.org/cd/mathmlkeys.xhtml#alternate-representation">alternate-representation</a>
from the <a href="http://www.openmath.org/cd/mathmlkeys.xhtml">mathmlkeys</a> content dictionary.</p>
<p>The <code>encoding</code> attribute describes the content type of the
annotation. The value of the <code>encoding</code> attribute may contain
a media type that identifies the data format for the encoding data. For
data formats that do not have an associated media type, implementors may
choose a self-describing character string to identify their content type.</p>
<p>The <code>src</code> attribute provides a mechanism to attach external
entities as annotations on MathML expressions.</p>
<pre class="mathml-fragment">
<annotation encoding="image/png" src="333/formula56.png"/></pre>
<p>The <code>annotation</code> element is a semantic mapping element that may
only be used as a child of the <code>semantics</code> element. While there is
no default rendering for the <code>annotation</code> element, a renderer may
use the information contained in an annotation to customize its rendering
of the annotated element.</p>
</div>
</div>
<div class="div3">
<h3><a id="mixing.elements.annotation.xml"></a>5.2.3 The <code><annotation-xml></code> element</h3>
<div class="div4">
<h4><a id="id.5.2.3.1"></a>5.2.3.1 Description</h4>
<p>The <code>annotation-xml</code> element is the container element for a
semantic annotation whose representation is structured markup. The <code>annotation-xml</code> element should contain the markup
elements, attributes, and character data for the annotation.</p>
</div>
<div class="div4">
<h4><a id="id.5.2.3.2"></a>5.2.3.2 Attributes</h4>
<table class="attributes">
<thead>
<tr>
<th>Name</th>
<th>values</th>
<th>default</th>
</tr>
</thead>
<tbody>
<tr>
<td rowspan="2" class="attname">definitionURL</td>
<td><a href="chapter2.xml#type.uri"><em>URI</em></a></td>
<td><em>none</em></td>
</tr>
<tr>
<td colspan="2" class="attdesc">The location of the annotation key symbol</td>
</tr>
<tr>
<td rowspan="2" class="attname">encoding</td>
<td><a href="chapter2.xml#type.string"><em>string</em></a></td>
<td><em>none</em></td>
</tr>
<tr>
<td colspan="2" class="attdesc">The encoding of the semantic information in the annotation</td>
</tr>
<tr>
<td rowspan="2" class="attname">cd</td>
<td><a href="chapter2.xml#type.string"><em>string</em></a></td>
<td>mathmlkeys</td>
</tr>
<tr>
<td colspan="2" class="attdesc">The content dictionary that contains the annotation key symbol</td>
</tr>
<tr>
<td rowspan="2" class="attname">name</td>
<td><a href="chapter2.xml#type.string"><em>string</em></a></td>
<td>alternate-representation</td>
</tr>
<tr>
<td colspan="2" class="attdesc">The name of the annotation key symbol</td>
</tr>
<tr>
<td rowspan="2" class="attname">src</td>
<td><a href="chapter2.xml#type.uri"><em>URI</em></a></td>
<td><em>none</em></td>
</tr>
<tr>
<td colspan="2" class="attdesc">The location of an external source for semantic information</td>
</tr>
</tbody>
</table>
<p>Taken together, the <code>cd</code> and <code>name</code> attributes
specify the annotation key symbol, which identifies the relationship
between the annotated element and the annotation, as described in
<a href="#mixing.annotation.elements">Section 5.1.1 Annotation elements</a>. The <code>definitionURL</code>
attribute provides an alternate way to reference the annotation key
symbol as a single attribute. If none of these attributes are present,
the annotation key symbol is the symbol
<a href="http://www.openmath.org/cd/mathmlkeys.xhtml#alternate-representation">alternate-representation</a>
from the <a href="http://www.openmath.org/cd/mathmlkeys.xhtml">mathmlkeys</a> content dictionary.</p>
<p>The <code>encoding</code> attribute describes the content type of the
annotation. The value of the <code>encoding</code> attribute may contain
a media type that identifies the data format for the encoding data. For
data formats that do not have an associated media type, implementors may
choose a self-describing character string to identify their content type.
In particular, as described above and in <a href="chapter6.xml#encoding-names">Section 6.2.4 Names of MathML Encodings</a>, MathML specifies
<code>MathML</code>, <code>MathML-Presentation</code>, and
<code>MathML-Content</code> as predefined values for the
<code>encoding</code> attribute. Finally, The <code>src</code>
attribute provides a mechanism to attach external XML entities as
annotations on MathML expressions.</p>
<pre class="mathml-fragment"><annotation-xml cd="mathmlkeys" name="contentequiv" encoding="MathML-Content">
<apply>
<plus/>
<apply><sin/><ci>x</ci></apply>
<cn>5</cn>
</apply>
</annotation-xml>
<annotation-xml encoding="application/openmath+xml">
<OMA xmlns="http://www.openmath.org/OpenMath">
<OMS cd="arith1" name="plus"/>
<OMA><OMS cd="transc1" name="sin"/><OMV name="x"/></OMA>
<OMI>5</OMI>
</OMA>
</annotation-xml></pre>
<p>When the MathML is being parsed as XML and
the annotation value is represented in an XML dialect other than MathML, the
namespace for the XML markup for the annotation should be identified by means of namespace
attributes and/or namespace prefixes on the annotation value. For instance:</p>
<pre class="mathml-fragment">
<annotation-xml encoding="application/xhtml+xml">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>E</title></head>
<body>
<p>The base of the natural logarithms, approximately 2.71828.</p>
</body>
</html>
</annotation-xml></pre>
<p>The <code>annotation-xml</code> element is a semantic mapping element that may only be used
as a child of the <code>semantics</code> element. While there is no default rendering for the
<code>annotation-xml</code> element, a renderer may use the information contained in an
annotation to customize its rendering of the annotated element.</p>
</div>
<div class="div4">
<h4><a id="html.annotation.xml"></a>5.2.3.3 Using <code>annotation-xml</code> in HTML documents</h4>
<p>Note that the Namespace extensibility used in the above examples
may not be available if the MathML is not being treated as an XML document. In particular
HTML parsers
treat <code>xmlns</code> attributes as ordinary attributes, so the OpenMath example would be classified as
invalid
by an HTML validator. The OpenMath elements would still be parsed as children of the
<code>annotation-xml</code> element, however they would be placed in the <em>MathML</em> namespace. The above examples are not rendered in the HTML version of this specification,
to ensure that that document is a valid HTML5 document.</p>
<p>The details of the HTML parser handling of <code>annotation-xml</code> is specified in <a href="appendixg.xml#HTML5">[HTML5]</a> and summarized in <a href="chapter6.xml#interf.html">Section 6.4.3 Mixing MathML and HTML</a>, however the main differences from the behavior of an XML parser that affect MathML
annotations are that the HTML parser does not treat <code>xmlns</code> attributes, nor <code>:</code> in element names as special and has built-in rules determining whether the three
"known" namespaces, HTML, SVG or MathML are used.
</p>
<ul>
<li>
<p>If the <code>annotation-xml</code> has an <code>encoding</code> attribute that is (ignoring case differences) "text/html" or "annotation/xhtml+xml"
then the content is parsed as HTML and placed (initially) in the HTML namespace.</p>