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
/
chapter6.html
1307 lines (1237 loc) · 73.2 KB
/
chapter6.html
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
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Interactions with the Host Environment</title>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<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="world-interactions"></a>6 Interactions with the Host Environment</h1>
<!-- TOP NAVIGATION BAR -->
<nav id="toc">
<ol class="toc">
<li><a href="Overview.html"><span class="secno"></span> Mathematical Markup Language (MathML) Version 4.0</a></li>
<li><a href="chapter5.html"><span class="secno">5 </span> Mixing Markup Languages for Mathematical Expressions</a></li>
<li><a href="chapter7.html"><span class="secno">7 </span> Characters, Entities and Fonts</a></li>
<li><a href="chapter6.html"><span class="secno">6 </span> Interactions with the Host Environment</a>
<ol class="toc">
<li><a href="chapter6.html#world.introduction"><span class="secno">6.1 </span> Introduction</a>
</li>
<li><a href="chapter6.html#world.invoking.processors"><span class="secno">6.2 </span> Invoking MathML Processors</a>
<ol class="toc">
<li><a href="chapter6.html#world.recognizing.mathml"><span class="secno">6.2.1 </span> Recognizing MathML in XML</a>
</li>
<li><a href="chapter6.html#world.recognizing.mathml.html"><span class="secno">6.2.2 </span> Recognizing MathML in HTML</a>
</li>
<li><a href="chapter6.html#world.resource.types"><span class="secno">6.2.3 </span> Resource Types for MathML Documents</a>
</li>
<li><a href="chapter6.html#encoding-names"><span class="secno">6.2.4 </span> Names of MathML Encodings</a>
</li>
</ol>
</li>
<li><a href="chapter6.html#world-int-transfers"><span class="secno">6.3 </span> Transferring MathML</a>
<ol class="toc">
<li><a href="chapter6.html#world-int-transf-flavors"><span class="secno">6.3.1 </span> Basic Transfer Flavor Names and Contents</a>
</li>
<li><a href="chapter6.html#world-int-transf-recommend"><span class="secno">6.3.2 </span> Recommended Behaviors when Transferring</a>
</li>
<li><a href="chapter6.html#world-int-transf-discuss"><span class="secno">6.3.3 </span> Discussion</a>
</li>
<li><a href="chapter6.html#world-int-transf-exa"><span class="secno">6.3.4 </span> Examples</a>
<ol class="toc">
<li><a href="chapter6.html#id.6.3.4.1"><span class="secno">6.3.4.1 </span> Example 1</a>
</li>
<li><a href="chapter6.html#id.6.3.4.2"><span class="secno">6.3.4.2 </span> Example 2</a>
</li>
<li><a href="chapter6.html#id.6.3.4.3"><span class="secno">6.3.4.3 </span> Example 3</a>
</li>
<li><a href="chapter6.html#id.6.3.4.4"><span class="secno">6.3.4.4 </span> Example 4</a>
</li>
</ol>
</li>
</ol>
</li>
<li><a href="chapter6.html#world-int-combine-other"><span class="secno">6.4 </span> Combining MathML and Other Formats</a>
<ol class="toc">
<li><a href="chapter6.html#interf.xhtml"><span class="secno">6.4.1 </span> Mixing MathML and XHTML</a>
</li>
<li><a href="chapter6.html#interf.nonxml"><span class="secno">6.4.2 </span> Mixing MathML and non-XML contexts</a>
</li>
<li><a href="chapter6.html#interf.html"><span class="secno">6.4.3 </span> Mixing MathML and HTML</a>
</li>
<li><a href="chapter6.html#interf.link"><span class="secno">6.4.4 </span> Linking</a>
</li>
<li><a href="chapter6.html#interf.graphics"><span class="secno">6.4.5 </span> MathML and Graphical Markup</a>
</li>
</ol>
</li>
<li><a href="chapter6.html#world-int-style"><span class="secno">6.5 </span> Using CSS with MathML</a>
<ol class="toc">
<li><a href="chapter6.html#id.6.5.1"><span class="secno">6.5.1 </span> Order of processing attributes versus style sheets</a>
</li>
</ol>
</li>
</ol>
</li>
</ol>
</nav>
<div class="div1">
<div class="div2">
<h2><a id="world.introduction"></a>6.1 Introduction</h2>
<p>To be effective, MathML must work well with a wide variety of
renderers, processors, translators and editors. This chapter raises
some of the interface issues involved in generating and rendering
MathML. Since MathML exists primarily to encode mathematics in Web
documents, perhaps the most important interface issues relate to
embedding MathML in <a href="appendixg.html#HTML5">[HTML5]</a>, and
<a href="appendixg.html#XHTML">[XHTML]</a>, and in any newer HTML
when it appears.</p>
<p>There are three kinds of interface issues that arise in embedding
MathML in other XML documents. First, MathML markup must be recognized
as valid embedded XML
content, and not as an error. This issue could be seen primarily as a
question of managing namespaces in XML <a href="appendixg.html#Namespaces">[Namespaces]</a>.
</p>
<p>Second, in the case of HTML/XHTML, MathML rendering must be
integrated with browser software. Some browsers already implement
MathML rendering natively, and one can expect more browsers will do so
in the future. At the same time, other browsers
have developed infrastructure to facilitate the rendering of MathML
and other embedded XML content by third-party software or other
built-in technology. Examples of this built-in technology are the
sophisticated CSS rendering engines now available, and the powerful
implementations of JavaScript/ECMAScript that are becoming
common. Using these browser-specific mechanisms generally requires
additional interface markup of some sort to activate them. In the
case of CSS, there is a special restricted form of MathML3
<a href="appendixh.html#MathMLforCSS">[MathMLforCSS]</a> that is tailored for use with
CSS rendering engines that support CSS 2.1 <a href="appendixh.html#CSS21">[CSS21]</a>.
This restricted profile of MathML3 does not offer the full
expressiveness of MathML3, but it provides a portable simpler form
that can be rendered acceptably on the screen by modern CSS engines.
</p>
<p>Third, other tools for generating and processing MathML must be
able to communicate. A number of MathML tools have been or are
being developed, including editors, translators, computer algebra
systems, and other scientific software. However, since MathML
expressions tend to be lengthy, and prone to error when entered by
hand, special emphasis must be made to ensure that MathML can easily
be generated by user-friendly conversion and authoring tools, and
that these tools work together in a dependable, platform-independent,
and vendor-independent way.</p>
<p>
This chapter applies to both content and presentation markup, and describes
a particular processing model for the <code>semantics</code>, <code>annotation</code>
and <code>annotation-xml</code> elements described in
<a href="chapter5.html#mixing.semantic.annotations">Section 5.1 Annotation Framework</a>.
</p>
</div>
<div class="div2">
<h2><a id="world.invoking.processors"></a>6.2 Invoking MathML Processors</h2>
<div class="div3">
<h3><a id="world.recognizing.mathml"></a>6.2.1 Recognizing MathML in XML</h3>
<p>Within an XML document supporting namespaces <a href="appendixg.html#XML">[XML]</a>,
<a href="appendixg.html#Namespaces">[Namespaces]</a>, the preferred method to recognize
MathML markup is by the identification of the <code>math</code> element
in the MathML namespace by the use of the MathML namespace
URI <code>http://www.w3.org/1998/Math/MathML</code>.</p>
<p>The MathML namespace URI is the recommended method to embed MathML
within <a href="appendixg.html#XHTML">[XHTML]</a> documents. However, some user-agents may
require supplementary information to be available to allow them to invoke
specific extensions to process the MathML markup.</p>
<p>Markup-language specifications that wish to embed MathML may require
special conditions to recognize MathML markup that are independent of
this recommendation. The conditions should be similar to those expressed
in this recommendation, and the local names of the MathML elements should
remain the same as those defined in this recommendation.</p>
</div>
<div class="div3">
<h3><a id="world.recognizing.mathml.html"></a>6.2.2 Recognizing MathML in HTML</h3>
<p>HTML does not allow arbitrary namespaces, but has built in knowledge of the MathML
namespace.
The <code>math</code> element and its descendants will be placed in the <code>http://www.w3.org/1998/Math/MathML</code>
namespace by the HTML parser, and will appear to applications as if the input had
been XHTML with the namespace declared
as in the previous section. See <a href="#interf.html">Section 6.4.3 Mixing MathML and HTML</a> for detailed rules of the HTML parser's handling of MathML.</p>
</div>
<div class="div3">
<h3><a id="world.resource.types"></a>6.2.3 Resource Types for MathML Documents</h3>
<p>Although rendering MathML expressions often takes place in
a Web browser, other MathML processing functions take place more
naturally in other applications. Particularly common tasks include
opening a MathML expression in an equation editor or computer algebra
system. It is important therefore to specify the encoding names
by which MathML fragments should be identified.</p>
<p>Outside of those environments where XML namespaces are recognized,
media types <a href="appendixg.html#RFC2045">[RFC2045]</a>, <a href="appendixg.html#RFC2046">[RFC2046]</a> should
be used if possible to ensure the invocation of a MathML processor.
For those environments where media types are not appropriate, such as
clipboard formats on some platforms, the encoding names described
in the next section should be used.</p>
</div>
<div class="div3">
<h3><a id="encoding-names"></a>6.2.4 Names of MathML Encodings</h3>
<p>MathML contains two distinct vocabularies: one for encoding visual
presentation, defined in <a href="chapter3.html">Chapter 3 Presentation Markup</a>, and one for encoding
computational structure, defined in <a href="chapter4.html">Chapter 4 Content Markup</a>. Some MathML
applications may import and export only one of these two vocabularies,
while others may produce and consume each in a different way, and still
others may process both without any distinction between the two. The
following encoding names may be used to distinguish between content
and presentation MathML markup when needed.</p>
<ul>
<li>
<p><em>MathML-Presentation</em>:
The instance contains presentation MathML markup only.</p>
<ul>
<li>
<p>Media Type: <code>application/mathml-presentation+xml</code></p>
</li>
<li>
<p>Windows Clipboard Flavor: <code>MathML Presentation</code></p>
</li>
<li>
<p>Universal Type Identifier: <code>public.mathml.presentation</code></p>
</li>
</ul>
</li>
<li>
<p><em>MathML-Content</em>:
The instance contains content MathML markup only.</p>
<ul>
<li>
<p>Media Type: <code>application/mathml-content+xml</code></p>
</li>
<li>
<p>Windows Clipboard Flavor: <code>MathML Content</code></p>
</li>
<li>
<p>Universal Type Identifier: <code>public.mathml.content</code></p>
</li>
</ul>
</li>
<li>
<p><em>MathML</em> (generic):
The instance may contain presentation MathML markup, content MathML markup,
or a mixture of the two.</p>
<ul>
<li>
<p>File name extension: <code>.mml</code></p>
</li>
<li>
<p>Media Type: <code>application/mathml+xml</code></p>
</li>
<li>
<p>Windows Clipboard Flavor: <code>MathML</code></p>
</li>
<li>
<p>Universal Type Identifier: <code>public.mathml</code></p>
</li>
</ul>
</li>
</ul>
<p>See <a href="appendixb.html">Appendix B Media Types Registrations</a> for more details about each of these
encoding names.</p>
<p>MathML 2 specified the predefined encoding values <code>MathML</code>,
<code>MathML-Content</code>, and <code>MathML-Presentation</code> for the
<code>encoding</code> attribute on the <code>annotation-xml</code> element.
These values may be used as an alternative to the media type for backward
compatibility. See <a href="chapter5.html#mixing.alternate.representations">Section 5.1.3 Alternate representations</a> and
<a href="chapter5.html#mixing.content.equiv">Section 5.1.4 Content equivalents</a> for details.
Moreover, MathML 1.0 suggested the media-type <code>text/mathml</code>,
which has been superseded by <a href="appendixg.html#RFC3023">[RFC3023]</a>.</p>
</div>
</div>
<div class="div2">
<h2><a id="world-int-transfers"></a>6.3 Transferring MathML</h2>
<p>MathML expressions are often exchanged between applications using the
familiar copy-and-paste or drag-and-drop paradigms and are often stored
in files or exchanged over the HTTP protocol. This section provides
recommended ways to process MathML during these transfers.</p>
<p>The transfers of MathML fragments described in this section occur between
the contexts of two applications by making the MathML data available in
several flavors, often called <em>media types</em>, <em>clipboard
formats</em>, or <em>data flavors</em>. These flavors are typically
ordered by preference by the producing application, and are typically
examined in preference order by the consuming application. The
copy-and-paste paradigm allows an application to <em>place</em>
content in a central <em>clipboard</em>, with one data stream per
<em>clipboard format</em>; a consuming application negotiates by
choosing to read the data of the format it prefers. The drag-and-drop
paradigm allows an application to <em>offer</em> content by declaring
the available formats; a potential recipient accepts or rejects a drop
based on the list of available formats, and the drop action allows the
receiving application to request the delivery of the data in one of the
indicated formats. An HTTP GET transfer, as in <a href="appendixh.html#HTTP11">[HTTP11]</a>,
allows a client to submit a list of acceptable media types; the server
then delivers the data using the one of the indicated media types.
An HTTP POST transfer, as in <a href="appendixh.html#HTTP11">[HTTP11]</a>, allows a client
to submit data labelled with a media type that is acceptable to the
server application.</p>
<p>Current desktop platforms offer copy-and-paste and drag-and-drop
transfers using similar architectures, but with varying naming schemes
depending on the platform. HTTP transfers are all based on media types.
This section specifies what transfer types applications should provide,
how they should be named, and how they should handle the special
<code>semantics</code>, <code>annotation</code>, and <code>annotation-xml</code>
elements.</p>
<p>To summarize the three negotiation mechanisms, the following paragraphs
will describe transfer <em>flavors</em>, each with a <em>name</em>
(a character string) and <em>content</em> (a stream of binary data),
which are <em>offered</em>, <em>accepted</em>, and/or
<em>exported</em>.</p>
<div class="div3">
<h3><a id="world-int-transf-flavors"></a>6.3.1 Basic Transfer Flavor Names and Contents</h3>
<p>The names listed in <a href="#encoding-names">Section 6.2.4 Names of MathML Encodings</a> are the exact
strings that should be used to identify the transfer flavors that
correspond to the MathML encodings. On operating systems that allow
such, an application should register their support for these flavor
names (e.g. on Windows, a call to RegisterClipboardFormat, or, on the
Macintosh platform, declaration of support for the universal type
identifier in the application descriptor).</p>
<p>When transferring MathML, an application MUST ensure the content
of the data transfer is a
<a href="http://www.w3.org/TR/2004/REC-xml-20040204/#dt-wellformed">well-formed</a>
XML instance of a MathML document type. Specifically:
</p>
<ol type="1">
<li>
<p>The instance MAY begin with an XML declaration,
e.g. <?xml version="1.0"></p>
</li>
<li>
<p>The instance MUST contain exactly one root <code>math</code> element.</p>
</li>
<li>
<p>The instance MUST declare the MathML namespace
on the root <code>math</code> element.</p>
</li>
<li>
<p>The instance MAY use a <code>schemaLocation</code> attribute
on the <code>math</code> element to indicate the location of the MathML
schema that describes the MathML document type to which the instance
conforms. The presence of the <code>schemaLocation</code> attribute
does not require a consumer of the MathML instance to obtain or use
the referenced schema.</p>
</li>
<li>
<p>The instance SHOULD use numeric character references
(e.g. &#x03b1;) rather than character entity names
(e.g. &alpha;) for greater interoperability.</p>
</li>
<li>
<p>The instance MUST specify the character encoding, if it uses an
encoding other than UTF-8, either in the XML declaration, or by the use
of a byte-order mark (BOM) for UTF-16-encoded data.</p>
</li>
</ol>
</div>
<div class="div3">
<h3><a id="world-int-transf-recommend"></a>6.3.2 Recommended Behaviors when Transferring</h3>
<p>An application that transfers MathML markup SHOULD adhere to the following
conventions:</p>
<ol type="1">
<li>
<p>An application that supports pure presentation markup and/or pure
content markup SHOULD offer as many of these flavors as it has available.
</p>
</li>
<li>
<p>An application that only exports one MathML flavor SHOULD name it
<code>MathML</code> if it is unable to determine a more specific flavor.
</p>
</li>
<li>
<p>
If an application is able to determine a more specific flavor, it SHOULD
offer both the generic and specific transfer flavors, but it SHOULD only
deliver the specific flavor if it knows that the recipient supports it.
For an HTTP GET transfer, for example, the specific transfer types for
content and presentation markup should only be returned if they are
included in the the HTTP <code>Accept</code> header sent by the client.
</p>
</li>
<li>
<p>
An application that exports the two specific transfer flavors SHOULD
export both the content and presentation transfer flavors, as well as
the generic flavor, which SHOULD combine the other two flavors using
a top-level MathML <code>semantics</code> element
(see <a href="chapter5.html#mixing.top.level">Section 5.4.1 Top-level Parallel Markup</a>).</p>
</li>
<li>
<p>
When an application exports a MathML fragment whose only child of the
root element is a <code>semantics</code> element, it SHOULD offer, after
the above flavors, a transfer flavor for each <code>annotation</code> or
<code>annotation-xml</code> element, provided the transfer flavor can be
recognized and named based on the <code>encoding</code> attribute value,
and provided the annotation key is (the default)
<a href="http://www.openmath.org/cd/mathmlkeys.xhtml#alternate-representation">alternate-representation</a>.
The transfer content for each annotation should contain the character data
in the specified encoding (for an <code>annotation</code> element), or a
well-formed XML fragment (for an <code>annotation-xml</code> element), or
the data that results by requesting the URL given by the <code>src</code>
attribute (for an annotation reference).</p>
</li>
<li>
<p>As a final fallback, an application MAY export a version of
the data in a plain-text flavor (such as <code>text/plain</code>,
<code>CF_UNICODETEXT</code>, <code>UnicodeText</code>, or
<code>NSStringPboardType</code>). When an application has multiple
versions of an expression available, it may choose the version to
export as text at its discretion. Since some older MathML processors
expect MathML instances transferred as plain text to begin with a
<code>math</code> element, the text version SHOULD generally omit the XML
declaration, DOCTYPE declaration, and other XML prolog material that
would appear before the <code>math</code> element. The Unicode
text version of the data SHOULD always be the last flavor exported,
following the principle that exported flavors should be ordered with
the most specific flavor first and the least specific flavor last.
</p>
</li>
</ol>
</div>
<div class="div3">
<h3><a id="world-int-transf-discuss"></a>6.3.3 Discussion</h3>
<p>To determine whether a MathML instance is pure content markup or
pure presentation markup, the <code>math</code>, <code>semantics</code>,
<code>annotation</code> and <code>annotation-xml</code> elements should be
regarded as belonging to both the presentation and content markup
vocabularies. The <code>math</code> element is treated in this way
because it is required as the root element in any MathML transfer.
The <code>semantics</code> element and its child annotation elements
comprise an arbitrary annotation mechanism within MathML, and are
not tied to either presentation or content markup. Consequently,
an application that consumes MathML should always process these four
elements, even if it only implements one of the two vocabularies.</p>
<p>It is worth noting that the above recommendations allow agents
that produce MathML to provide binary data for the clipboard, for
example in an image or other application-specific format. The sole
method to do so is to reference the binary data using the <code>src</code>
attribute of an annotation, since XML character data does not allow
for the transfer of arbitrary byte-stream data.</p>
<p>While the above recommendations are intended to improve
interoperability between MathML-aware applications that use these
transfer paradigms, it should be noted that they do not guarantee
interoperability. For example, references to external resources
(e.g. stylesheets, etc.) in MathML data can cause interoperability
problems if the consumer of the data is unable to locate them,
as can happen when cutting and pasting HTML or other data types.
An application that makes use of references to external resources
is encouraged to make users aware of potential problems and provide
alternate ways to obtain the referenced resources. In general,
consumers of MathML data that contains references they cannot
resolve or do not understand should ignore the external references.
</p>
</div>
<div class="div3">
<h3><a id="world-int-transf-exa"></a>6.3.4 Examples</h3>
<div class="div4">
<h4><a id="id.6.3.4.1"></a>6.3.4.1 Example 1</h4>
<p>An e-Learning application has a database of quiz questions, some of
which contain MathML. The MathML comes from multiple sources, and the
e-Learning application merely passes the data on for display, but does
not have sophisticated MathML analysis capabilities. Consequently,
the application is not aware whether a given MathML instance is pure
presentation or pure content markup, nor does it know whether the
instance is valid with respect to a particular version of the MathML schema. It therefore
places the following data formats on the clipboard:</p>
<table id="table-flavor-a" class="data">
<thead>
<tr>
<th>Flavor Name</th>
<th>Flavor Content</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>MathML</code></td>
<td>
<pre class="mathml-fragment">
<math xmlns="http://www.w3.org/1998/Math/MathML">...</math></pre>
</td>
</tr>
<tr>
<td><code>Unicode Text</code></td>
<td>
<pre class="mathml-fragment"><math xmlns="http://www.w3.org/1998/Math/MathML">...</math></pre>
</td>
</tr>
</tbody>
</table>
</div>
<div class="div4">
<h4><a id="id.6.3.4.2"></a>6.3.4.2 Example 2</h4>
<p>An equation editor on the Windows platform is able to generate pure presentation markup,
valid with respect to MathML 3. Consequently, it
exports the following flavors:</p>
<table id="table-flavor-b" class="data">
<thead>
<tr>
<th>Flavor Name</th>
<th>Flavor Content</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>MathML Presentation</code></td>
<td>
<pre class="mathml-fragment">
<math xmlns="http://www.w3.org/1998/Math/MathML">...</math></pre>
</td>
</tr>
<tr>
<td><code>Tiff</code></td>
<td>(a rendering sample)</td>
</tr>
<tr>
<td><code>Unicode Text</code></td>
<td>
<pre class="mathml-fragment"><math xmlns="http://www.w3.org/1998/Math/MathML">...</math></pre>
</td>
</tr>
</tbody>
</table>
</div>
<div class="div4">
<h4><a id="id.6.3.4.3"></a>6.3.4.3 Example 3</h4>
<p>A schema-based content management system on the Mac OS X platform contains multiple
MathML
representations of a collection of mathematical expressions, including mixed
markup from authors, pure content markup for interfacing to symbolic computation
engines, and pure presentation markup for print publication. Due to the system's
use of schemata, markup is stored with a namespace prefix.
The system therefore can transfer the following data:</p>
<table id="table-flavor-c" class="data">
<thead>
<tr>
<th>Flavor Name</th>
<th>Flavor Content</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>public.mathml.presentation</code></td>
<td>
<pre class="mathml-fragment">
<math xmlns="http://www.w3.org/1998/Math/MathML"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://www.w3.org/Math/XMLSchema/mathml3/mathml3.xsd">
<mrow>
...
<mrow>
</math></pre>
</td>
</tr>
<tr>
<td><code>public.mathml.content</code></td>
<td>
<pre class="mathml-fragment">
<math xmlns="http://www.w3.org/1998/Math/MathML"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://www.w3.org/Math/XMLSchema/mathml3/mathml3.xsd">
<apply>
...
<apply>
</math></pre>
</td>
</tr>
<tr>
<td><code>public.mathml</code></td>
<td>
<pre class="mathml-fragment">
<math xmlns="http://www.w3.org/1998/Math/MathML"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://www.w3.org/Math/XMLSchema/mathml3/mathml3.xsd">
<mrow>
<apply>
... content markup within presentation markup ...
</apply>
...
</mrow>
</math> </pre>
</td>
</tr>
<tr>
<td><code>public.plain-text.tex</code></td>
<td>
<pre class="TeX">{x \over x-1}</pre>
</td>
</tr>
<tr>
<td><code>public.plain-text</code></td>
<td>
<pre class="mathml-fragment"><math xmlns="http://www.w3.org/1998/Math/MathML"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://www.w3.org/Math/XMLSchema/mathml3/mathml3.xsd">
<mrow>
...
<mrow>
</math></pre>
</td>
</tr>
</tbody>
</table>
</div>
<div class="div4">
<h4><a id="id.6.3.4.4"></a>6.3.4.4 Example 4</h4>
<p>A similar content management system is web-based and delivers MathML
representations of mathematical expressions. The system is able to produce
MathML-Presentation, MathML-Content, TeX and pictures in TIFF format.
In web-pages being browsed, it could produce a MathML fragment such as the following:
</p>
<pre class="mathml-fragment"><math xmlns="http://www.w3.org/1998/Math/MathML">
<semantics>
<mrow>...</mrow>
<annotation-xml encoding="MathML-Content">...</annotation-xml>
<annotation encoding="TeX">{1 \over x}</annotation>
<annotation encoding="image/tiff" src="formula3848.tiff"/>
</semantics>
</math>
</pre>
<p>A web-browser on the Windows platform that receives such a fragment and tries to export
it as part of
a drag-and-drop action, can offer the following flavors:</p>
<table id="table-flavor-d" class="data">
<thead>
<tr>
<th>Flavor Name</th>
<th>Flavor Content</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>MathML Presentation</code></td>
<td>
<pre class="mathml-fragment">
<math xmlns="http://www.w3.org/1998/Math/MathML"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://www.w3.org/Math/XMLSchema/mathml3/mathml3.xsd">
<mrow>
...
<mrow>
</math></pre>
</td>
</tr>
<tr>
<td><code>MathML Content</code></td>
<td>
<pre class="mathml-fragment">
<math xmlns="http://www.w3.org/1998/Math/MathML"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://www.w3.org/Math/XMLSchema/mathml3/mathml3.xsd">
<apply>
...
<apply>
</math></pre>
</td>
</tr>
<tr>
<td><code>MathML</code></td>
<td>
<pre class="mathml-fragment">
<math xmlns="http://www.w3.org/1998/Math/MathML"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://www.w3.org/Math/XMLSchema/mathml3/mathml3.xsd">
<mrow>
<apply>
... content markup within presentation markup ...
</apply>
...
</mrow>
</math> </pre>
</td>
</tr>
<tr>
<td><code>TeX</code></td>
<td>
<pre class="TeX">{x \over x-1}</pre>
</td>
</tr>
<tr>
<td><code>CF_TIFF</code></td>
<td>(the content of the picture file, requested from formula3848.tiff)</td>
</tr>
<tr>
<td><code>CF_UNICODETEXT</code></td>
<td>
<pre class="mathml-fragment"><math xmlns="http://www.w3.org/1998/Math/MathML"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://www.w3.org/Math/XMLSchema/mathml3/mathml3.xsd">
<mrow>
...
<mrow>
</math></pre>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="div2">
<h2><a id="world-int-combine-other"></a>6.4 Combining MathML and Other Formats</h2>
<p>MathML is usually used in combination with other markup languages.
The most typical case is perhaps the use of MathML within a
document-level markup language, such as HTML or DocBook. It is also
common that other object-level markup languages are also included in a
compound document format, such as MathML and SVG in HTML5.
Other common use cases include mixing other markup within
MathML. For example, an authoring tool might insert an element
representing a cursor position or other state information within
MathML markup, so that an author can pick up editing where
it was broken off.</p>
<p>Most document markup languages have some concept of an inline
equation, (or graphic, object, etc.) so there is a typically a natural
way to incorporate MathML instances into the content
model. However, in the other direction, embedding of markup within
MathML is not so clear cut, since in many MathML elements, the role of
child elements is defined by position. For example, the first
child of an <code>apply</code> must be an operator, and the second child
of an <code>mfrac</code> is the denominator. The proper behavior when
foreign markup appears in such contexts is problematic. Even when such
behavior can be defined in a particular context, it presents an
implementation challenge for generic MathML processors.</p>
<p>For this reason, the default MathML schema does not allow
foreign markup elements to be included within MathML
instances.</p>
<p>In the standard schema, elements from other namespaces
are not allowed, but attributes from other namespaces are permitted.
MathML processors that encounter unknown XML markup should behave
as follows:
</p>
<ol type="1">
<li>
<p>An attribute from a non-MathML namespace should be silently ignored.</p>
</li>
<li>
<p>An element from a non-MathML namespace should be treated
as an error, except in an <code>annotation-xml</code> element.
If the element is a child of a presentation element, it should be
handled as described in <a href="chapter3.html#presm.merror">Section 3.3.5 Error Message <code><merror></code></a>.
If the element is a child of a content element, it should be
handled as described in <a href="chapter4.html#contm.cerror">Section 4.2.9 Error Markup <code><cerror></code></a>.</p>
</li>
</ol>
<p>
For example, if the second child of an <code>mfrac</code> element is an
unknown element, the fraction should be rendered with a denominator
that indicates the error.
</p>
<p>When designing a compound document format in which MathML is included in a larger
document type, the designer may extend the content model of MathML to allow additional
elements. For example, a common extension is to extend the MathML schema such that
elements from non-MathML namespaces are
allowed in token elements, but not in other elements. MathML processors that
encounter unknown markup should behave as follows:
</p>
<ol type="1">
<li>
<p>An unrecognized XML attribute should be silently ignored.</p>
</li>
<li>
<p>An unrecognized element in a MathML token element should be silently ignored.</p>
</li>
<li>
<p>An element from a non-MathML namespace should be treated
as an error, except in an <code>annotation-xml</code> element.
If the element is a child of a presentation element, it should be
handled as described in <a href="chapter3.html#presm.merror">Section 3.3.5 Error Message <code><merror></code></a>.
If the element is a child of a content element, it should be
handled as described in <a href="chapter4.html#contm.cerror">Section 4.2.9 Error Markup <code><cerror></code></a>.</p>
</li>
</ol>
<p>Extending the schema in this way is easily achieved using the Relax NG schema described
in <a href="appendixa.html">Appendix A Parsing MathML</a>, it may be as simple as including the MathML schema whilst overriding the content
model of <code>mtext</code>:
</p>
<pre>
default namespace m = "http://www.w3.org/1998/Math/MathML"
include "mathml3.rnc" {
mtext = element mtext {mtext.attributes, (token.content|anyElement)*}
}
</pre>
<p>
The definition given here would allow any well formed XML that is not in the MathML
namespace as a child of <code>mtext</code>. In practice this may be too lax. For example, an XHTML+MathML Schema may just want
to allow inline XHTML elements as additional children of <code>mtext</code>. This may be achieved by replacing <code>anyElement</code> by a suitable production from the schema for the host document type, see <a href="#interf.xhtml">Section 6.4.1 Mixing MathML and XHTML</a>.</p>
<p>Considerations about mixing markup vocabularies in compound
documents arise when a compound document type is first designed.
But once the document type is fixed, it is not generally practical
for specific software tools to further modify the content model to
suit their needs.
However, it is still frequently the case that such tools may need to
store additional information within a MathML instance.
Since MathML is most often generated by authoring tools, a particularly common and
important case is where an authoring tool needs to store
information about its internal state along with a MathML expression, so an author
can resume editing from a previous state. For example, placeholders
may be used to indicate incomplete parts of an expression, or a
insertion point within an expression may need to be stored.</p>
<p>An application that needs to persist private data within a MathML
expression should generally attempt to do so without altering the
underlying content model, even in situations where it is feasible to
do so. To support this requirement, regardless of what may be allowed
by the content model of a particular compound document format, MathML
permits the storage
of private data via the following strategies:</p>
<ol type="1">
<li>
<p>In a format that permits the use of XML Namespaces,
for small amounts of data, attributes from other namespaces
are allowed on all MathML elements.</p>
</li>
<li>
<p>For larger amounts of data, applications may use the
<code>semantics</code> element, as described in
<a href="chapter5.html#mixing.semantic.annotations">Section 5.1 Annotation Framework</a>.</p>
</li>
<li>
<p>For authoring tools and other applications that need to
associate particular actions with presentation MathML subtrees,
e.g. to mark an incomplete expression to be filled in by an author,
the <code>maction</code> element may be used, as described in
<a href="chapter3.html#presm.maction">Section 3.7.1 Bind Action to Sub-Expression
<code><maction></code></a>.</p>