rdoc-f95 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. data/History.txt +4 -0
  2. data/Manifest.txt +79 -0
  3. data/PostInstall.txt +7 -0
  4. data/README.rdoc +147 -0
  5. data/Rakefile +28 -0
  6. data/bin/rdoc-f95 +70 -0
  7. data/lib/rdoc-f95.rb +306 -0
  8. data/lib/rdoc-f95/code_objects.rb +776 -0
  9. data/lib/rdoc-f95/diagram.rb +342 -0
  10. data/lib/rdoc-f95/dot.rb +249 -0
  11. data/lib/rdoc-f95/generator.rb +1088 -0
  12. data/lib/rdoc-f95/generator/chm.rb +113 -0
  13. data/lib/rdoc-f95/generator/chm/chm.rb +98 -0
  14. data/lib/rdoc-f95/generator/html.rb +370 -0
  15. data/lib/rdoc-f95/generator/html/hefss.rb +414 -0
  16. data/lib/rdoc-f95/generator/html/html.rb +708 -0
  17. data/lib/rdoc-f95/generator/html/kilmer.rb +418 -0
  18. data/lib/rdoc-f95/generator/html/one_page_html.rb +121 -0
  19. data/lib/rdoc-f95/generator/ri.rb +229 -0
  20. data/lib/rdoc-f95/generator/xhtml.rb +106 -0
  21. data/lib/rdoc-f95/generator/xhtml/ctop.xsl +1318 -0
  22. data/lib/rdoc-f95/generator/xhtml/mathml.xsl +42 -0
  23. data/lib/rdoc-f95/generator/xhtml/pmathml.xsl +612 -0
  24. data/lib/rdoc-f95/generator/xhtml/pmathmlcss.xsl +872 -0
  25. data/lib/rdoc-f95/generator/xhtml/xhtml.rb +732 -0
  26. data/lib/rdoc-f95/generator/xml.rb +120 -0
  27. data/lib/rdoc-f95/generator/xml/rdf.rb +113 -0
  28. data/lib/rdoc-f95/generator/xml/xml.rb +111 -0
  29. data/lib/rdoc-f95/install.rb +166 -0
  30. data/lib/rdoc-f95/markup.rb +506 -0
  31. data/lib/rdoc-f95/markup/formatter.rb +14 -0
  32. data/lib/rdoc-f95/markup/fragments.rb +337 -0
  33. data/lib/rdoc-f95/markup/inline.rb +361 -0
  34. data/lib/rdoc-f95/markup/install.rb +57 -0
  35. data/lib/rdoc-f95/markup/lines.rb +152 -0
  36. data/lib/rdoc-f95/markup/mathml_wrapper.rb +91 -0
  37. data/lib/rdoc-f95/markup/preprocess.rb +71 -0
  38. data/lib/rdoc-f95/markup/sample/rdoc2latex.rb +16 -0
  39. data/lib/rdoc-f95/markup/sample/sample.rb +42 -0
  40. data/lib/rdoc-f95/markup/to_flow.rb +185 -0
  41. data/lib/rdoc-f95/markup/to_html.rb +357 -0
  42. data/lib/rdoc-f95/markup/to_html_crossref.rb +123 -0
  43. data/lib/rdoc-f95/markup/to_latex.rb +328 -0
  44. data/lib/rdoc-f95/markup/to_test.rb +50 -0
  45. data/lib/rdoc-f95/markup/to_xhtml_texparser.rb +234 -0
  46. data/lib/rdoc-f95/options.rb +745 -0
  47. data/lib/rdoc-f95/parsers/parse_c.rb +775 -0
  48. data/lib/rdoc-f95/parsers/parse_f95.rb +2499 -0
  49. data/lib/rdoc-f95/parsers/parse_rb.rb +2587 -0
  50. data/lib/rdoc-f95/parsers/parse_simple.rb +39 -0
  51. data/lib/rdoc-f95/parsers/parserfactory.rb +99 -0
  52. data/lib/rdoc-f95/ri.rb +2 -0
  53. data/lib/rdoc-f95/ri/cache.rb +188 -0
  54. data/lib/rdoc-f95/ri/descriptions.rb +147 -0
  55. data/lib/rdoc-f95/ri/display.rb +244 -0
  56. data/lib/rdoc-f95/ri/driver.rb +435 -0
  57. data/lib/rdoc-f95/ri/formatter.rb +603 -0
  58. data/lib/rdoc-f95/ri/paths.rb +105 -0
  59. data/lib/rdoc-f95/ri/reader.rb +106 -0
  60. data/lib/rdoc-f95/ri/util.rb +81 -0
  61. data/lib/rdoc-f95/ri/writer.rb +64 -0
  62. data/lib/rdoc-f95/stats.rb +23 -0
  63. data/lib/rdoc-f95/template.rb +64 -0
  64. data/lib/rdoc-f95/tokenstream.rb +33 -0
  65. data/lib/rdoc-f95/usage.rb +210 -0
  66. data/script/console +10 -0
  67. data/script/destroy +14 -0
  68. data/script/generate +14 -0
  69. data/test/test_helper.rb +3 -0
  70. data/test/test_rdoc-f95.rb +11 -0
  71. metadata +156 -0
@@ -0,0 +1,229 @@
1
+ require 'rdoc-f95/generator'
2
+ require 'rdoc-f95/markup/to_flow'
3
+
4
+ require 'rdoc-f95/ri/cache'
5
+ require 'rdoc-f95/ri/reader'
6
+ require 'rdoc-f95/ri/writer'
7
+ require 'rdoc-f95/ri/descriptions'
8
+
9
+ class RDocF95::Generator::RI
10
+
11
+ ##
12
+ # Generator may need to return specific subclasses depending on the
13
+ # options they are passed. Because of this we create them using a factory
14
+
15
+ def self.for(options)
16
+ new(options)
17
+ end
18
+
19
+ class << self
20
+ protected :new
21
+ end
22
+
23
+ ##
24
+ # Set up a new RDocF95::Generator::RI.
25
+
26
+ def initialize(options) #:not-new:
27
+ @options = options
28
+ @ri_writer = RDocF95::RI::Writer.new "."
29
+ @markup = RDocF95::Markup.new
30
+ @to_flow = RDocF95::Markup::ToFlow.new
31
+
32
+ @generated = {}
33
+ end
34
+
35
+ ##
36
+ # Build the initial indices and output objects based on an array of
37
+ # TopLevel objects containing the extracted information.
38
+
39
+ def generate(toplevels)
40
+ RDocF95::TopLevel.all_classes_and_modules.each do |cls|
41
+ process_class cls
42
+ end
43
+ end
44
+
45
+ def process_class(from_class)
46
+ generate_class_info(from_class)
47
+
48
+ # now recure into this classes constituent classess
49
+ from_class.each_classmodule do |mod|
50
+ process_class(mod)
51
+ end
52
+ end
53
+
54
+ def generate_class_info(cls)
55
+ if cls === RDocF95::NormalModule
56
+ cls_desc = RDocF95::RI::ModuleDescription.new
57
+ else
58
+ cls_desc = RDocF95::RI::ClassDescription.new
59
+ cls_desc.superclass = cls.superclass
60
+ end
61
+
62
+ cls_desc.name = cls.name
63
+ cls_desc.full_name = cls.full_name
64
+ cls_desc.comment = markup(cls.comment)
65
+
66
+ cls_desc.attributes = cls.attributes.sort.map do |a|
67
+ RDocF95::RI::Attribute.new(a.name, a.rw, markup(a.comment))
68
+ end
69
+
70
+ cls_desc.constants = cls.constants.map do |c|
71
+ RDocF95::RI::Constant.new(c.name, c.value, markup(c.comment))
72
+ end
73
+
74
+ cls_desc.includes = cls.includes.map do |i|
75
+ RDocF95::RI::IncludedModule.new(i.name)
76
+ end
77
+
78
+ class_methods, instance_methods = method_list(cls)
79
+
80
+ cls_desc.class_methods = class_methods.map do |m|
81
+ RDocF95::RI::MethodSummary.new(m.name)
82
+ end
83
+
84
+ cls_desc.instance_methods = instance_methods.map do |m|
85
+ RDocF95::RI::MethodSummary.new(m.name)
86
+ end
87
+
88
+ update_or_replace(cls_desc)
89
+
90
+ class_methods.each do |m|
91
+ generate_method_info(cls_desc, m)
92
+ end
93
+
94
+ instance_methods.each do |m|
95
+ generate_method_info(cls_desc, m)
96
+ end
97
+ end
98
+
99
+ def generate_method_info(cls_desc, method)
100
+ meth_desc = RDocF95::RI::MethodDescription.new
101
+ meth_desc.name = method.name
102
+ meth_desc.full_name = cls_desc.full_name
103
+ if method.singleton
104
+ meth_desc.full_name += "::"
105
+ else
106
+ meth_desc.full_name += "#"
107
+ end
108
+ meth_desc.full_name << method.name
109
+
110
+ meth_desc.comment = markup(method.comment)
111
+ meth_desc.params = params_of(method)
112
+ meth_desc.visibility = method.visibility.to_s
113
+ meth_desc.is_singleton = method.singleton
114
+ meth_desc.block_params = method.block_params
115
+
116
+ meth_desc.aliases = method.aliases.map do |a|
117
+ RDocF95::RI::AliasName.new(a.name)
118
+ end
119
+
120
+ @ri_writer.add_method(cls_desc, meth_desc)
121
+ end
122
+
123
+ private
124
+
125
+ ##
126
+ # Returns a list of class and instance methods that we'll be documenting
127
+
128
+ def method_list(cls)
129
+ list = cls.method_list
130
+ unless @options.show_all
131
+ list = list.find_all do |m|
132
+ m.visibility == :public || m.visibility == :protected || m.force_documentation
133
+ end
134
+ end
135
+
136
+ c = []
137
+ i = []
138
+ list.sort.each do |m|
139
+ if m.singleton
140
+ c << m
141
+ else
142
+ i << m
143
+ end
144
+ end
145
+ return c,i
146
+ end
147
+
148
+ def params_of(method)
149
+ if method.call_seq
150
+ method.call_seq
151
+ else
152
+ params = method.params || ""
153
+
154
+ p = params.gsub(/\s*\#.*/, '')
155
+ p = p.tr("\n", " ").squeeze(" ")
156
+ p = "(" + p + ")" unless p[0] == ?(
157
+
158
+ if (block = method.block_params)
159
+ block.gsub!(/\s*\#.*/, '')
160
+ block = block.tr("\n", " ").squeeze(" ")
161
+ if block[0] == ?(
162
+ block.sub!(/^\(/, '').sub!(/\)/, '')
163
+ end
164
+ p << " {|#{block.strip}| ...}"
165
+ end
166
+ p
167
+ end
168
+ end
169
+
170
+ def markup(comment)
171
+ return nil if !comment || comment.empty?
172
+
173
+ # Convert leading comment markers to spaces, but only
174
+ # if all non-blank lines have them
175
+
176
+ if comment =~ /^(?>\s*)[^\#]/
177
+ content = comment
178
+ else
179
+ content = comment.gsub(/^\s*(#+)/) { $1.tr('#',' ') }
180
+ end
181
+ @markup.convert(content, @to_flow)
182
+ end
183
+
184
+ ##
185
+ # By default we replace existing classes with the same name. If the
186
+ # --merge option was given, we instead merge this definition into an
187
+ # existing class. We add our methods, aliases, etc to that class, but do
188
+ # not change the class's description.
189
+
190
+ def update_or_replace(cls_desc)
191
+ old_cls = nil
192
+
193
+ if @options.merge
194
+ rdr = RDocF95::RI::Reader.new RDocF95::RI::Cache.new(@options.op_dir)
195
+
196
+ namespace = rdr.top_level_namespace
197
+ namespace = rdr.lookup_namespace_in(cls_desc.name, namespace)
198
+ if namespace.empty?
199
+ $stderr.puts "You asked me to merge this source into existing "
200
+ $stderr.puts "documentation. This file references a class or "
201
+ $stderr.puts "module called #{cls_desc.name} which I don't"
202
+ $stderr.puts "have existing documentation for."
203
+ $stderr.puts
204
+ $stderr.puts "Perhaps you need to generate its documentation first"
205
+ exit 1
206
+ else
207
+ old_cls = namespace[0]
208
+ end
209
+ end
210
+
211
+ prev_cls = @generated[cls_desc.full_name]
212
+
213
+ if old_cls and not prev_cls then
214
+ old_desc = rdr.get_class old_cls
215
+ cls_desc.merge_in old_desc
216
+ end
217
+
218
+ if prev_cls then
219
+ cls_desc.merge_in prev_cls
220
+ end
221
+
222
+ @generated[cls_desc.full_name] = cls_desc
223
+
224
+ @ri_writer.remove_class cls_desc
225
+ @ri_writer.add_class cls_desc
226
+ end
227
+
228
+ end
229
+
@@ -0,0 +1,106 @@
1
+ require 'fileutils'
2
+
3
+ require 'rdoc-f95/generator'
4
+ require 'rdoc-f95/generator/html'
5
+ require 'rdoc-f95/markup/to_html'
6
+
7
+ ##
8
+ # We're responsible for generating all the HTML files from the object tree
9
+ # defined in code_objects.rb. We generate:
10
+ #
11
+ # [files] an html file for each input file given. These
12
+ # input files appear as objects of class
13
+ # TopLevel
14
+ #
15
+ # [classes] an html file for each class or module encountered.
16
+ # These classes are not grouped by file: if a file
17
+ # contains four classes, we'll generate an html
18
+ # file for the file itself, and four html files
19
+ # for the individual classes.
20
+ #
21
+ # [indices] we generate three indices for files, classes,
22
+ # and methods. These are displayed in a browser
23
+ # like window with three index panes across the
24
+ # top and the selected description below
25
+ #
26
+ # Method descriptions appear in whatever entity (file, class, or module) that
27
+ # contains them.
28
+ #
29
+ # We generate files in a structure below a specified subdirectory, normally
30
+ # +doc+.
31
+ #
32
+ # opdir
33
+ # |
34
+ # |___ files
35
+ # | |__ per file summaries
36
+ # |
37
+ # |___ classes
38
+ # |__ per class/module descriptions
39
+ #
40
+ # HTML is generated using the Template class.
41
+
42
+ class RDocF95::Generator::XHTML < RDocF95::Generator::HTML
43
+
44
+ def gen_an_index(collection, title, template, filename)
45
+ template = RDocF95::TemplatePage.new @template::FR_INDEX_BODY, template
46
+ res = []
47
+ collection.sort.each do |f|
48
+ if f.document_self
49
+ res << { "href" => f.path, "name" => f.index_name }
50
+ end
51
+ end
52
+
53
+ values = {
54
+ "entries" => res,
55
+ 'list_title' => CGI.escapeHTML(title),
56
+ 'index_url' => main_url,
57
+ 'charset' => @options.charset,
58
+ 'style_url' => style_url('', @options.css),
59
+ 'mathml_xsl_url' => style_url('', "mathml.xsl"),
60
+ }
61
+
62
+ open filename, 'w' do |f|
63
+ template.write_html_on(f, values)
64
+ end
65
+ end
66
+
67
+ ##
68
+ # Build the initial indices and output objects
69
+ # based on an array of TopLevel objects containing
70
+ # the extracted information.
71
+
72
+ def generate(*args)
73
+ super(*args)
74
+
75
+ copy_xsls
76
+ end
77
+
78
+ def copy_xsls
79
+ xsl_files = ["mathml.xsl", "pmathmlcss.xsl", "ctop.xsl", "pmathml.xsl"]
80
+ xsl_dir = "rdoc-f95/generator/xhtml"
81
+ hit = 0
82
+ $LOAD_PATH.each{ |path|
83
+ hit = 0
84
+ xsl_files.each{ |file|
85
+ hit += 1 if ::File.exist?(::File.join(path, xsl_dir, file))
86
+ }
87
+ if hit >= 4
88
+ xsl_files.each{ |file|
89
+ ::FileUtils.copy(::File.join(path, xsl_dir, file), "./")
90
+ }
91
+ break
92
+ else
93
+ hit = 0
94
+ end
95
+ }
96
+ if hit < 4
97
+ $stderr.puts "Couldn't find xsl files (#{xsl_files.join(', ')})\n"
98
+ exit
99
+ end
100
+ end
101
+
102
+ end
103
+
104
+ class RDocF95::Generator::XHTMLInOne < RDocF95::Generator::HTMLInOne
105
+
106
+ end
@@ -0,0 +1,1318 @@
1
+ <xsl:stylesheet
2
+ version="1.0"
3
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4
+ xmlns:mml="http://www.w3.org/1998/Math/MathML"
5
+ >
6
+
7
+ <!--
8
+ $Id: ctop.xsl,v 1.1 2008-03-08 16:14:54 morikawa Exp $
9
+
10
+ Copyright David Carlisle 2001, 2002.
11
+
12
+ Use and distribution of this code are permitted under the terms of the <a
13
+ href="http://www.w3.org/Consortium/Legal/copyright-software-19980720"
14
+ >W3C Software Notice and License</a>.
15
+ -->
16
+
17
+ <xsl:output method="xml" />
18
+
19
+ <xsl:template mode="c2p" match="*">
20
+ <xsl:copy>
21
+ <xsl:copy-of select="@*"/>
22
+ <xsl:apply-templates mode="c2p"/>
23
+ </xsl:copy>
24
+ </xsl:template>
25
+
26
+
27
+ <!-- 4.4.1.1 cn -->
28
+
29
+ <xsl:template mode="c2p" match="mml:cn">
30
+ <mml:mn><xsl:apply-templates mode="c2p"/></mml:mn>
31
+ </xsl:template>
32
+
33
+ <xsl:template mode="c2p" match="mml:cn[@type='complex-cartesian']">
34
+ <mml:mrow>
35
+ <mml:mn><xsl:apply-templates mode="c2p" select="text()[1]"/></mml:mn>
36
+ <mml:mo>+</mml:mo>
37
+ <mml:mn><xsl:apply-templates mode="c2p" select="text()[2]"/></mml:mn>
38
+ <mml:mo><!--&#8290;--><!--invisible times--></mml:mo>
39
+ <mml:mi>i<!-- imaginary i --></mml:mi>
40
+ </mml:mrow>
41
+ </xsl:template>
42
+
43
+ <xsl:template mode="c2p" match="mml:cn[@type='rational']">
44
+ <mml:mrow>
45
+ <mml:mn><xsl:apply-templates mode="c2p" select="text()[1]"/></mml:mn>
46
+ <mml:mo>/</mml:mo>
47
+ <mml:mn><xsl:apply-templates mode="c2p" select="text()[2]"/></mml:mn>
48
+ </mml:mrow>
49
+ </xsl:template>
50
+
51
+ <xsl:template mode="c2p" match="mml:cn[@type='integer']">
52
+ <xsl:choose>
53
+ <xsl:when test="not(@base) or @base=10">
54
+ <mml:mn><xsl:apply-templates mode="c2p"/></mml:mn>
55
+ </xsl:when>
56
+ <xsl:otherwise>
57
+ <mml:msub>
58
+ <mml:mn><xsl:apply-templates mode="c2p"/></mml:mn>
59
+ <mml:mn><xsl:value-of select="@base"/></mml:mn>
60
+ </mml:msub>
61
+ </xsl:otherwise>
62
+ </xsl:choose>
63
+ </xsl:template>
64
+
65
+ <xsl:template mode="c2p" match="mml:cn[@type='complex-polar']">
66
+ <mml:mrow>
67
+ <mml:mn><xsl:apply-templates mode="c2p" select="text()[1]"/></mml:mn>
68
+ <mml:mo><!--&#8290;--><!--invisible times--></mml:mo>
69
+ <mml:msup>
70
+ <mml:mi>e<!-- exponential e--></mml:mi>
71
+ <mml:mrow>
72
+ <mml:mi>i<!-- imaginary i--></mml:mi>
73
+ <mml:mo><!--&#8290;--><!--invisible times--></mml:mo>
74
+ <mml:mn><xsl:apply-templates mode="c2p" select="text()[2]"/></mml:mn>
75
+ </mml:mrow>
76
+ </mml:msup>
77
+ </mml:mrow>
78
+ </xsl:template>
79
+
80
+ <xsl:template mode="c2p" match="mml:cn[@type='e-notation']">
81
+ <mml:mn><xsl:apply-templates mode="c2p" select="text()[1]"/>E<xsl:apply-templates mode="c2p" select="text()[2]"/></mml:mn>
82
+ </xsl:template>
83
+
84
+ <!-- 4.4.1.1 ci -->
85
+
86
+ <xsl:template mode="c2p" match="mml:ci/text()">
87
+ <mml:mi><xsl:value-of select="."/></mml:mi>
88
+ </xsl:template>
89
+
90
+ <xsl:template mode="c2p" match="mml:ci">
91
+ <mml:mrow><xsl:apply-templates mode="c2p"/></mml:mrow>
92
+ </xsl:template>
93
+
94
+ <!-- 4.4.1.2 csymbol -->
95
+
96
+ <xsl:template mode="c2p" match="mml:csymbol/text()">
97
+ <mml:mo><xsl:apply-templates mode="c2p"/></mml:mo>
98
+ </xsl:template>
99
+
100
+ <xsl:template mode="c2p" match="mml:csymbol">
101
+ <mml:mrow><xsl:apply-templates mode="c2p"/></mml:mrow>
102
+ </xsl:template>
103
+
104
+ <!-- 4.4.2.1 apply 4.4.2.2 reln -->
105
+
106
+ <xsl:template mode="c2p" match="mml:apply|mml:reln">
107
+ <mml:mrow>
108
+ <xsl:apply-templates mode="c2p" select="*[1]">
109
+ <xsl:with-param name="p" select="10"/>
110
+ </xsl:apply-templates>
111
+ <mml:mo><!--&#8290;--><!--invisible times--></mml:mo>
112
+ <mml:mfenced open="(" close=")" separators=",">
113
+ <xsl:apply-templates mode="c2p" select="*[position()>1]"/>
114
+ </mml:mfenced>
115
+ </mml:mrow>
116
+ </xsl:template>
117
+
118
+ <!-- 4.4.2.3 fn -->
119
+ <xsl:template mode="c2p" match="mml:fn">
120
+ <mml:mrow><xsl:apply-templates mode="c2p"/></mml:mrow>
121
+ </xsl:template>
122
+
123
+ <!-- 4.4.2.4 interval -->
124
+ <xsl:template mode="c2p" match="mml:interval[*[2]]">
125
+ <mml:mfenced open="[" close="]"><xsl:apply-templates mode="c2p"/></mml:mfenced>
126
+ </xsl:template>
127
+ <xsl:template mode="c2p" match="mml:interval[*[2]][@closure='open']">
128
+ <mml:mfenced open="(" close=")"><xsl:apply-templates mode="c2p"/></mml:mfenced>
129
+ </xsl:template>
130
+ <xsl:template mode="c2p" match="mml:interval[*[2]][@closure='open-closed']">
131
+ <mml:mfenced open="(" close="]"><xsl:apply-templates mode="c2p"/></mml:mfenced>
132
+ </xsl:template>
133
+ <xsl:template mode="c2p" match="mml:interval[*[2]][@closure='closed-open']">
134
+ <mml:mfenced open="[" close=")"><xsl:apply-templates mode="c2p"/></mml:mfenced>
135
+ </xsl:template>
136
+
137
+ <xsl:template mode="c2p" match="mml:interval">
138
+ <mml:mfenced open="{{" close="}}"><xsl:apply-templates mode="c2p"/></mml:mfenced>
139
+ </xsl:template>
140
+
141
+ <!-- 4.4.2.5 inverse -->
142
+
143
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:inverse]]">
144
+ <mml:msup>
145
+ <xsl:apply-templates mode="c2p" select="*[2]"/>
146
+ <mml:mrow><mml:mo>(</mml:mo><mml:mn>-1</mml:mn><mml:mo>)</mml:mo></mml:mrow>
147
+ </mml:msup>
148
+ </xsl:template>
149
+
150
+ <!-- 4.4.2.6 sep -->
151
+
152
+ <!-- 4.4.2.7 condition -->
153
+ <xsl:template mode="c2p" match="mml:condition">
154
+ <mml:mrow><xsl:apply-templates mode="c2p"/></mml:mrow>
155
+ </xsl:template>
156
+
157
+ <!-- 4.4.2.8 declare -->
158
+ <xsl:template mode="c2p" match="mml:declare"/>
159
+
160
+ <!-- 4.4.2.9 lambda -->
161
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:lambda]]">
162
+ <mml:mrow>
163
+ <mml:mi>&#955;<!--lambda--></mml:mi>
164
+ <mml:mrow><xsl:apply-templates mode="c2p" select="mml:bvar/*"/></mml:mrow>
165
+ <mml:mo>.</mml:mo>
166
+ <mml:mfenced>
167
+ <xsl:apply-templates mode="c2p" select="*[last()]"/>
168
+ </mml:mfenced>
169
+ </mml:mrow>
170
+ </xsl:template>
171
+
172
+
173
+ <!-- 4.4.2.10 compose -->
174
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:compose]]">
175
+ <xsl:param name="p" select="0"/>
176
+ <xsl:call-template name="infix">
177
+ <xsl:with-param name="this-p" select="1"/>
178
+ <xsl:with-param name="p" select="$p"/>
179
+ <xsl:with-param name="mo"><mml:mo>&#8728;<!-- o --></mml:mo></xsl:with-param>
180
+ </xsl:call-template>
181
+ </xsl:template>
182
+
183
+
184
+ <!-- 4.4.2.11` ident -->
185
+ <xsl:template mode="c2p" match="mml:ident">
186
+ <mml:mo>id</mml:mo>
187
+ </xsl:template>
188
+
189
+ <!-- 4.4.2.12` domain -->
190
+ <xsl:template mode="c2p" match="mml:domain">
191
+ <mml:mo>domain</mml:mo>
192
+ </xsl:template>
193
+
194
+ <!-- 4.4.2.13` codomain -->
195
+ <xsl:template mode="c2p" match="mml:codomain">
196
+ <mml:mo>codomain</mml:mo>
197
+ </xsl:template>
198
+
199
+ <!-- 4.4.2.14` image -->
200
+ <xsl:template mode="c2p" match="mml:image">
201
+ <mml:mo>image</mml:mo>
202
+ </xsl:template>
203
+
204
+ <!-- 4.4.2.15` domainofapplication -->
205
+ <xsl:template mode="c2p" match="mml:domainofapplication">
206
+ <mml:error/>
207
+ </xsl:template>
208
+
209
+ <!-- 4.4.2.16` piecewise -->
210
+ <xsl:template mode="c2p" match="mml:piecewise">
211
+ <mml:mrow>
212
+ <mml:mo>{</mml:mo>
213
+ <mml:mtable>
214
+ <xsl:for-each select="mml:piece|mml:otherwise">
215
+ <mml:mtr>
216
+ <mml:mtd><xsl:apply-templates mode="c2p" select="*[1]"/></mml:mtd>
217
+ <mml:mtd><mml:mtext>&#160; if &#160;</mml:mtext></mml:mtd>
218
+ <mml:mtd><xsl:apply-templates mode="c2p" select="*[2]"/></mml:mtd>
219
+ </mml:mtr>
220
+ </xsl:for-each>
221
+ </mml:mtable>
222
+ </mml:mrow>
223
+ </xsl:template>
224
+
225
+
226
+ <!-- 4.4.3.1 quotient -->
227
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:quotient]]">
228
+ <mml:mrow>
229
+ <mml:mo>&#8970;<!-- lfloor--></mml:mo>
230
+ <xsl:apply-templates mode="c2p" select="*[2]"/>
231
+ <mml:mo>/</mml:mo>
232
+ <xsl:apply-templates mode="c2p" select="*[3]"/>
233
+ <mml:mo>&#8971;<!-- rfloor--></mml:mo>
234
+ </mml:mrow>
235
+ </xsl:template>
236
+
237
+
238
+
239
+ <!-- 4.4.3.2 factorial -->
240
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:factorial]]">
241
+ <mml:mrow>
242
+ <xsl:apply-templates mode="c2p" select="*[2]">
243
+ <xsl:with-param name="p" select="7"/>
244
+ </xsl:apply-templates>
245
+ <mml:mo>!</mml:mo>
246
+ </mml:mrow>
247
+ </xsl:template>
248
+
249
+
250
+ <!-- 4.4.3.3 divide -->
251
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:divide]]">
252
+ <xsl:param name="p" select="0"/>
253
+ <xsl:call-template name="binary">
254
+ <xsl:with-param name="mo"><mml:mo>/</mml:mo></xsl:with-param>
255
+ <xsl:with-param name="p" select="$p"/>
256
+ <xsl:with-param name="this-p" select="3"/>
257
+ </xsl:call-template>
258
+ </xsl:template>
259
+
260
+
261
+ <!-- 4.4.3.4 max min-->
262
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:max]]">
263
+ <mml:mrow>
264
+ <mml:mo>max</mml:mo>
265
+ <xsl:call-template name="set"/>
266
+ </mml:mrow>
267
+ </xsl:template>
268
+
269
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:min]]">
270
+ <mml:mrow>
271
+ <mml:mo>max</mml:mo>
272
+ <xsl:call-template name="set"/>
273
+ </mml:mrow>
274
+ </xsl:template>
275
+
276
+ <!-- 4.4.3.5 minus-->
277
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:minus] and count(*)=2]">
278
+ <mml:mrow>
279
+ <mml:mo>&#8722;<!--minus--></mml:mo>
280
+ <xsl:apply-templates mode="c2p" select="*[2]">
281
+ <xsl:with-param name="p" select="5"/>
282
+ </xsl:apply-templates>
283
+ </mml:mrow>
284
+ </xsl:template>
285
+
286
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:minus] and count(*)&gt;2]">
287
+ <xsl:param name="p" select="0"/>
288
+ <xsl:call-template name="binary">
289
+ <xsl:with-param name="mo"><mml:mo>&#8722;<!--minus--></mml:mo></xsl:with-param>
290
+ <xsl:with-param name="p" select="$p"/>
291
+ <xsl:with-param name="this-p" select="2"/>
292
+ </xsl:call-template>
293
+ </xsl:template>
294
+
295
+ <!-- 4.4.3.6 plus-->
296
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:plus]]">
297
+ <xsl:param name="p" select="0"/>
298
+ <mml:mrow>
299
+ <xsl:if test="$p &gt; 2"><mml:mo>(</mml:mo></xsl:if>
300
+ <xsl:for-each select="*[position()&gt;1]">
301
+ <xsl:if test="position() &gt; 1">
302
+ <mml:mo>
303
+ <xsl:choose>
304
+ <xsl:when test="self::mml:apply[*[1][self::mml:times] and
305
+ *[2][self::mml:apply/*[1][self::mml:minus] or self::mml:cn[not(mml:sep) and
306
+ (number(.) &lt; 0)]]]">&#8722;<!--minus--></xsl:when>
307
+ <xsl:otherwise>+</xsl:otherwise>
308
+ </xsl:choose>
309
+ </mml:mo>
310
+ </xsl:if>
311
+ <xsl:choose>
312
+ <xsl:when test="self::mml:apply[*[1][self::mml:times] and
313
+ *[2][self::mml:cn[not(mml:sep) and (number(.) &lt;0)]]]">
314
+ <mml:mrow>
315
+ <mml:mn><xsl:value-of select="-(*[2])"/></mml:mn>
316
+ <mml:mo><!--&#8290;--><!--invisible times--></mml:mo>
317
+ <xsl:apply-templates mode="c2p" select=".">
318
+ <xsl:with-param name="first" select="2"/>
319
+ <xsl:with-param name="p" select="2"/>
320
+ </xsl:apply-templates>
321
+ </mml:mrow>
322
+ </xsl:when>
323
+ <xsl:when test="self::mml:apply[*[1][self::mml:times] and
324
+ *[2][self::mml:apply/*[1][self::mml:minus]]]">
325
+ <mml:mrow>
326
+ <xsl:apply-templates mode="c2p" select="./*[2]/*[2]"/>
327
+ <xsl:apply-templates mode="c2p" select=".">
328
+ <xsl:with-param name="first" select="2"/>
329
+ <xsl:with-param name="p" select="2"/>
330
+ </xsl:apply-templates>
331
+ </mml:mrow>
332
+ </xsl:when>
333
+ <xsl:otherwise>
334
+ <xsl:apply-templates mode="c2p" select=".">
335
+ <xsl:with-param name="p" select="2"/>
336
+ </xsl:apply-templates>
337
+ </xsl:otherwise>
338
+ </xsl:choose>
339
+ </xsl:for-each>
340
+ <xsl:if test="$p &gt; 2"><mml:mo>)</mml:mo></xsl:if>
341
+ </mml:mrow>
342
+ </xsl:template>
343
+
344
+
345
+ <!-- 4.4.3.7 power -->
346
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:power]]">
347
+ <mml:msup>
348
+ <xsl:apply-templates mode="c2p" select="*[2]">
349
+ <xsl:with-param name="p" select="5"/>
350
+ </xsl:apply-templates>
351
+ <xsl:apply-templates mode="c2p" select="*[3]">
352
+ <xsl:with-param name="p" select="5"/>
353
+ </xsl:apply-templates>
354
+ </mml:msup>
355
+ </xsl:template>
356
+
357
+ <!-- 4.4.3.8 remainder -->
358
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:rem]]">
359
+ <xsl:param name="p" select="0"/>
360
+ <xsl:call-template name="binary">
361
+ <xsl:with-param name="mo"><mml:mo>mod</mml:mo></xsl:with-param>
362
+ <xsl:with-param name="p" select="$p"/>
363
+ <xsl:with-param name="this-p" select="3"/>
364
+ </xsl:call-template>
365
+ </xsl:template>
366
+
367
+ <!-- 4.4.3.9 times-->
368
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:times]]" name="times">
369
+ <xsl:param name="p" select="0"/>
370
+ <xsl:param name="first" select="1"/>
371
+ <mml:mrow>
372
+ <xsl:if test="$p &gt; 3"><mml:mo>(</mml:mo></xsl:if>
373
+ <xsl:for-each select="*[position()&gt;1]">
374
+ <xsl:if test="position() &gt; 1">
375
+ <mml:mo>
376
+ <xsl:choose>
377
+ <xsl:when test="self::mml:cn">&#215;<!-- times --></xsl:when>
378
+ <xsl:otherwise><!--&#8290;--><!--invisible times--></xsl:otherwise>
379
+ </xsl:choose>
380
+ </mml:mo>
381
+ </xsl:if>
382
+ <xsl:if test="position()&gt;= $first">
383
+ <xsl:apply-templates mode="c2p" select=".">
384
+ <xsl:with-param name="p" select="3"/>
385
+ </xsl:apply-templates>
386
+ </xsl:if>
387
+ </xsl:for-each>
388
+ <xsl:if test="$p &gt; 3"><mml:mo>)</mml:mo></xsl:if>
389
+ </mml:mrow>
390
+ </xsl:template>
391
+
392
+
393
+ <!-- 4.4.3.10 root -->
394
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:root] and not(mml:degree) or mml:degree=2]" priority="4">
395
+ <mml:msqrt>
396
+ <xsl:apply-templates mode="c2p" select="*[position()&gt;1]"/>
397
+ </mml:msqrt>
398
+ </xsl:template>
399
+
400
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:root]]">
401
+ <mml:mroot>
402
+ <xsl:apply-templates mode="c2p" select="*[position()&gt;1 and not(self::mml:degree)]"/>
403
+ <mml:mrow><xsl:apply-templates mode="c2p" select="mml:degree/*"/></mml:mrow>
404
+ </mml:mroot>
405
+ </xsl:template>
406
+
407
+ <!-- 4.4.3.11 gcd -->
408
+ <xsl:template mode="c2p" match="mml:gcd">
409
+ <mml:mo>gcd</mml:mo>
410
+ </xsl:template>
411
+
412
+ <!-- 4.4.3.12 and -->
413
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:and]]">
414
+ <xsl:param name="p" select="0"/>
415
+ <xsl:call-template name="infix">
416
+ <xsl:with-param name="this-p" select="2"/>
417
+ <xsl:with-param name="p" select="$p"/>
418
+ <xsl:with-param name="mo"><mml:mo>&#8743;<!-- and --></mml:mo></xsl:with-param>
419
+ </xsl:call-template>
420
+ </xsl:template>
421
+
422
+
423
+ <!-- 4.4.3.13 or -->
424
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:or]]">
425
+ <xsl:param name="p" select="0"/>
426
+ <xsl:call-template name="infix">
427
+ <xsl:with-param name="this-p" select="3"/>
428
+ <xsl:with-param name="p" select="$p"/>
429
+ <xsl:with-param name="mo"><mml:mo>&#8744;<!-- or --></mml:mo></xsl:with-param>
430
+ </xsl:call-template>
431
+ </xsl:template>
432
+
433
+ <!-- 4.4.3.14 xor -->
434
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:xor]]">
435
+ <xsl:param name="p" select="0"/>
436
+ <xsl:call-template name="infix">
437
+ <xsl:with-param name="this-p" select="3"/>
438
+ <xsl:with-param name="p" select="$p"/>
439
+ <xsl:with-param name="mo"><mml:mo>xor</mml:mo></xsl:with-param>
440
+ </xsl:call-template>
441
+ </xsl:template>
442
+
443
+
444
+ <!-- 4.4.3.15 not -->
445
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:not]]">
446
+ <mml:mrow>
447
+ <mml:mo>&#172;<!-- not --></mml:mo>
448
+ <xsl:apply-templates mode="c2p" select="*[2]">
449
+ <xsl:with-param name="p" select="7"/>
450
+ </xsl:apply-templates>
451
+ </mml:mrow>
452
+ </xsl:template>
453
+
454
+
455
+
456
+
457
+ <!-- 4.4.3.16 implies -->
458
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:implies]]">
459
+ <xsl:param name="p" select="0"/>
460
+ <xsl:call-template name="binary">
461
+ <xsl:with-param name="mo"><mml:mo>&#8658;<!-- Rightarrow --></mml:mo></xsl:with-param>
462
+ <xsl:with-param name="p" select="$p"/>
463
+ <xsl:with-param name="this-p" select="3"/>
464
+ </xsl:call-template>
465
+ </xsl:template>
466
+
467
+
468
+ <!-- 4.4.3.17 forall -->
469
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:forall]]">
470
+ <mml:mrow>
471
+ <mml:mi>&#8704;<!--forall--></mml:mi>
472
+ <mml:mrow><xsl:apply-templates mode="c2p" select="mml:bvar[not(current()/mml:condition)]/*|mml:condition/*"/></mml:mrow>
473
+ <mml:mo>.</mml:mo>
474
+ <mml:mfenced>
475
+ <xsl:apply-templates mode="c2p" select="*[last()]"/>
476
+ </mml:mfenced>
477
+ </mml:mrow>
478
+ </xsl:template>
479
+
480
+
481
+
482
+ <!-- 4.4.3.18 exists -->
483
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:exists]]">
484
+ <mml:mrow>
485
+ <mml:mi>&#8707;<!--exists--></mml:mi>
486
+ <mml:mrow><xsl:apply-templates mode="c2p" select="mml:bvar[not(current()/mml:condition)]/*|mml:condition/*"/></mml:mrow>
487
+ <mml:mo>.</mml:mo>
488
+ <mml:mfenced>
489
+ <xsl:apply-templates mode="c2p" select="*[last()]"/>
490
+ </mml:mfenced>
491
+ </mml:mrow>
492
+ </xsl:template>
493
+
494
+
495
+ <!-- 4.4.3.19 abs -->
496
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:abs]]">
497
+ <mml:mrow>
498
+ <mml:mo>|</mml:mo>
499
+ <xsl:apply-templates mode="c2p" select="*[2]"/>
500
+ <mml:mo>|</mml:mo>
501
+ </mml:mrow>
502
+ </xsl:template>
503
+
504
+
505
+
506
+ <!-- 4.4.3.20 conjugate -->
507
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:conjugate]]">
508
+ <mml:mover>
509
+ <xsl:apply-templates mode="c2p" select="*[2]"/>
510
+ <mml:mo>&#175;<!-- overline --></mml:mo>
511
+ </mml:mover>
512
+ </xsl:template>
513
+
514
+ <!-- 4.4.3.21 arg -->
515
+ <xsl:template mode="c2p" match="mml:arg">
516
+ <mml:mo>arg</mml:mo>
517
+ </xsl:template>
518
+
519
+
520
+ <!-- 4.4.3.22 real -->
521
+ <xsl:template mode="c2p" match="mml:real">
522
+ <mml:mo>&#8475;<!-- real --></mml:mo>
523
+ </xsl:template>
524
+
525
+ <!-- 4.4.3.23 imaginary -->
526
+ <xsl:template mode="c2p" match="mml:imaginary">
527
+ <mml:mo>&#8465;<!-- imaginary --></mml:mo>
528
+ </xsl:template>
529
+
530
+ <!-- 4.4.3.24 lcm -->
531
+ <xsl:template mode="c2p" match="mml:lcm">
532
+ <mml:mo>lcm</mml:mo>
533
+ </xsl:template>
534
+
535
+
536
+ <!-- 4.4.3.25 floor -->
537
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:floor]]">
538
+ <mml:mrow>
539
+ <mml:mo>&#8970;<!-- lfloor--></mml:mo>
540
+ <xsl:apply-templates mode="c2p" select="*[2]"/>
541
+ <mml:mo>&#8971;<!-- rfloor--></mml:mo>
542
+ </mml:mrow>
543
+ </xsl:template>
544
+
545
+
546
+ <!-- 4.4.3.25 ceiling -->
547
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:ceiling]]">
548
+ <mml:mrow>
549
+ <mml:mo>&#8968;<!-- lceil--></mml:mo>
550
+ <xsl:apply-templates mode="c2p" select="*[2]"/>
551
+ <mml:mo>&#8969;<!-- rceil--></mml:mo>
552
+ </mml:mrow>
553
+ </xsl:template>
554
+
555
+ <!-- 4.4.4.1 eq -->
556
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:eq]]">
557
+ <xsl:param name="p" select="0"/>
558
+ <xsl:call-template name="infix">
559
+ <xsl:with-param name="this-p" select="1"/>
560
+ <xsl:with-param name="p" select="$p"/>
561
+ <xsl:with-param name="mo"><mml:mo>=</mml:mo></xsl:with-param>
562
+ </xsl:call-template>
563
+ </xsl:template>
564
+
565
+ <!-- 4.4.4.2 neq -->
566
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:neq]]">
567
+ <xsl:param name="p" select="0"/>
568
+ <xsl:call-template name="infix">
569
+ <xsl:with-param name="this-p" select="1"/>
570
+ <xsl:with-param name="p" select="$p"/>
571
+ <xsl:with-param name="mo"><mml:mo>&#8800;<!-- neq --></mml:mo></xsl:with-param>
572
+ </xsl:call-template>
573
+ </xsl:template>
574
+
575
+ <!-- 4.4.4.3 eq -->
576
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:gt]]">
577
+ <xsl:param name="p" select="0"/>
578
+ <xsl:call-template name="infix">
579
+ <xsl:with-param name="this-p" select="1"/>
580
+ <xsl:with-param name="p" select="$p"/>
581
+ <xsl:with-param name="mo"><mml:mo>&gt;</mml:mo></xsl:with-param>
582
+ </xsl:call-template>
583
+ </xsl:template>
584
+
585
+ <!-- 4.4.4.4 lt -->
586
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:lt]]">
587
+ <xsl:param name="p" select="0"/>
588
+ <xsl:call-template name="infix">
589
+ <xsl:with-param name="this-p" select="1"/>
590
+ <xsl:with-param name="p" select="$p"/>
591
+ <xsl:with-param name="mo"><mml:mo>&lt;</mml:mo></xsl:with-param>
592
+ </xsl:call-template>
593
+ </xsl:template>
594
+
595
+ <!-- 4.4.4.5 geq -->
596
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:geq]]">
597
+ <xsl:param name="p" select="0"/>
598
+ <xsl:call-template name="infix">
599
+ <xsl:with-param name="this-p" select="1"/>
600
+ <xsl:with-param name="p" select="$p"/>
601
+ <xsl:with-param name="mo"><mml:mo>&#8805;</mml:mo></xsl:with-param>
602
+ </xsl:call-template>
603
+ </xsl:template>
604
+
605
+ <!-- 4.4.4.6 geq -->
606
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:leq]]">
607
+ <xsl:param name="p" select="0"/>
608
+ <xsl:call-template name="infix">
609
+ <xsl:with-param name="this-p" select="1"/>
610
+ <xsl:with-param name="p" select="$p"/>
611
+ <xsl:with-param name="mo"><mml:mo>&#8804;</mml:mo></xsl:with-param>
612
+ </xsl:call-template>
613
+ </xsl:template>
614
+
615
+ <!-- 4.4.4.7 equivalent -->
616
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:equivalent]]">
617
+ <xsl:param name="p" select="0"/>
618
+ <xsl:call-template name="infix">
619
+ <xsl:with-param name="this-p" select="1"/>
620
+ <xsl:with-param name="p" select="$p"/>
621
+ <xsl:with-param name="mo"><mml:mo>&#8801;</mml:mo></xsl:with-param>
622
+ </xsl:call-template>
623
+ </xsl:template>
624
+
625
+ <!-- 4.4.4.8 approx -->
626
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:approx]]">
627
+ <xsl:param name="p" select="0"/>
628
+ <xsl:call-template name="infix">
629
+ <xsl:with-param name="this-p" select="1"/>
630
+ <xsl:with-param name="p" select="$p"/>
631
+ <xsl:with-param name="mo"><mml:mo>&#8771;</mml:mo></xsl:with-param>
632
+ </xsl:call-template>
633
+ </xsl:template>
634
+
635
+
636
+ <!-- 4.4.4.9 factorof -->
637
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:factorof]]">
638
+ <xsl:param name="p" select="0"/>
639
+ <xsl:call-template name="binary">
640
+ <xsl:with-param name="mo"><mml:mo>|</mml:mo></xsl:with-param>
641
+ <xsl:with-param name="p" select="$p"/>
642
+ <xsl:with-param name="this-p" select="3"/>
643
+ </xsl:call-template>
644
+ </xsl:template>
645
+
646
+ <!-- 4.4.5.1 int -->
647
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:int]]">
648
+ <mml:mrow>
649
+ <mml:msubsup>
650
+ <mml:mi>&#8747;<!--int--></mml:mi>
651
+ <mml:mrow><xsl:apply-templates mode="c2p" select="mml:lowlimit/*|mml:interval/*[1]|mml:condition/*"/></mml:mrow>
652
+ <mml:mrow><xsl:apply-templates mode="c2p" select="mml:uplimit/*|mml:interval/*[2]"/></mml:mrow>
653
+ </mml:msubsup>
654
+ <xsl:apply-templates mode="c2p" select="*[last()]"/>
655
+ <mml:mo>d</mml:mo><xsl:apply-templates mode="c2p" select="mml:bvar"/>
656
+ </mml:mrow>
657
+ </xsl:template>
658
+
659
+ <!-- 4.4.5.2 diff -->
660
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:diff] and mml:ci and count(*)=2]" priority="2">
661
+ <mml:msup>
662
+ <mml:mrow><xsl:apply-templates mode="c2p" select="*[2]"/></mml:mrow>
663
+ <mml:mo>&#8242;<!--prime--></mml:mo>
664
+ </mml:msup>
665
+ </xsl:template>
666
+
667
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:diff]]" priority="1">
668
+ <mml:mfrac>
669
+ <xsl:choose>
670
+ <xsl:when test="mml:bvar/mml:degree">
671
+ <mml:mrow><mml:msup><mml:mo>d</mml:mo><xsl:apply-templates mode="c2p" select="mml:bvar/mml:degree/node()"/></mml:msup>
672
+ <xsl:apply-templates mode="c2p" select="*[last()]"/></mml:mrow>
673
+ <mml:mrow><mml:mo>d</mml:mo><mml:msup><xsl:apply-templates mode="c2p"
674
+ select="mml:bvar/node()"/><xsl:apply-templates mode="c2p"
675
+ select="mml:bvar/mml:degree/node()"/></mml:msup>
676
+ </mml:mrow>
677
+ </xsl:when>
678
+ <xsl:otherwise>
679
+ <mml:mrow><mml:mo>d</mml:mo><xsl:apply-templates mode="c2p" select="*[last()]"/></mml:mrow>
680
+ <mml:mrow><mml:mo>d</mml:mo><xsl:apply-templates mode="c2p" select="mml:bvar"/></mml:mrow>
681
+ </xsl:otherwise>
682
+ </xsl:choose>
683
+ </mml:mfrac>
684
+ </xsl:template>
685
+
686
+
687
+ <!-- 4.4.5.3 partialdiff -->
688
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:partialdiff] and mml:list and mml:ci and count(*)=3]" priority="2">
689
+ <mml:mrow>
690
+ <mml:msub><mml:mo>D</mml:mo><mml:mrow>
691
+ <xsl:for-each select="mml:list[1]/*">
692
+ <xsl:apply-templates mode="c2p" select="."/>
693
+ <xsl:if test="position()&lt;last()"><mml:mo>,</mml:mo></xsl:if>
694
+ </xsl:for-each>
695
+ </mml:mrow></mml:msub>
696
+ <mml:mrow><xsl:apply-templates mode="c2p" select="*[3]"/></mml:mrow>
697
+ </mml:mrow>
698
+ </xsl:template>
699
+
700
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:partialdiff]]" priority="1">
701
+ <mml:mfrac>
702
+ <mml:mrow><mml:msup><mml:mo>&#8706;<!-- partial --></mml:mo>
703
+ <mml:mrow>
704
+ <xsl:choose>
705
+ <xsl:when test="mml:degree">
706
+ <xsl:apply-templates mode="c2p" select="mml:degree/node()"/>
707
+ </xsl:when>
708
+ <xsl:when test="mml:bvar/mml:degree[string(number(.))='NaN']">
709
+ <xsl:for-each select="mml:bvar/mml:degree">
710
+ <xsl:apply-templates mode="c2p" select="node()"/>
711
+ <xsl:if test="position()&lt;last()"><mml:mo>+</mml:mo></xsl:if>
712
+ </xsl:for-each>
713
+ <xsl:if test="count(mml:bvar[not(mml:degree)])&gt;0">
714
+ <mml:mo>+</mml:mo><mml:mn><xsl:value-of select="count(mml:bvar[not(mml:degree)])"/></mml:mn>
715
+ </xsl:if>
716
+ </xsl:when>
717
+ <xsl:otherwise>
718
+ <mml:mn><xsl:value-of select="sum(mml:bvar/mml:degree)+count(mml:bvar[not(mml:degree)])"/></mml:mn>
719
+ </xsl:otherwise>
720
+ </xsl:choose>
721
+ </mml:mrow>
722
+ </mml:msup>
723
+ <xsl:apply-templates mode="c2p" select="*[last()]"/></mml:mrow>
724
+ <mml:mrow>
725
+ <xsl:for-each select="mml:bvar">
726
+ <mml:mrow>
727
+ <mml:mo>&#8706;<!-- partial --></mml:mo><mml:msup><xsl:apply-templates mode="c2p" select="node()"/>
728
+ <mml:mrow><xsl:apply-templates mode="c2p" select="mml:degree/node()"/></mml:mrow>
729
+ </mml:msup>
730
+ </mml:mrow>
731
+ </xsl:for-each>
732
+ </mml:mrow>
733
+ </mml:mfrac>
734
+ </xsl:template>
735
+
736
+ <!-- 4.4.5.4 lowlimit-->
737
+ <xsl:template mode="c2p" match="mml:lowlimit"/>
738
+
739
+ <!-- 4.4.5.5 uplimit-->
740
+ <xsl:template mode="c2p" match="mml:uplimit"/>
741
+
742
+ <!-- 4.4.5.6 bvar-->
743
+ <xsl:template mode="c2p" match="mml:bvar">
744
+ <mml:mi><xsl:apply-templates mode="c2p"/></mml:mi>
745
+ <xsl:if test="following-sibling::mml:bvar"><mml:mo>,</mml:mo></xsl:if>
746
+ </xsl:template>
747
+
748
+ <!-- 4.4.5.7 degree-->
749
+ <xsl:template mode="c2p" match="mml:degree"/>
750
+
751
+ <!-- 4.4.5.8 divergence-->
752
+ <xsl:template mode="c2p" match="mml:divergence">
753
+ <mml:mo>div</mml:mo>
754
+ </xsl:template>
755
+
756
+ <!-- 4.4.5.9 grad-->
757
+ <xsl:template mode="c2p" match="mml:grad">
758
+ <mml:mo>grad</mml:mo>
759
+ </xsl:template>
760
+
761
+ <!-- 4.4.5.10 curl -->
762
+ <xsl:template mode="c2p" match="mml:curl">
763
+ <mml:mo>curl</mml:mo>
764
+ </xsl:template>
765
+
766
+
767
+ <!-- 4.4.5.11 laplacian-->
768
+ <xsl:template mode="c2p" match="mml:laplacian">
769
+ <mml:msup><mml:mo>&#8711;<!-- nabla --></mml:mo><mml:mn>2</mml:mn></mml:msup>
770
+ </xsl:template>
771
+
772
+ <!-- 4.4.6.1 set -->
773
+
774
+ <xsl:template mode="c2p" match="mml:set">
775
+ <xsl:call-template name="set"/>
776
+ </xsl:template>
777
+
778
+ <!-- 4.4.6.2 list -->
779
+
780
+ <xsl:template mode="c2p" match="mml:list">
781
+ <xsl:call-template name="set">
782
+ <xsl:with-param name="o" select="'('"/>
783
+ <xsl:with-param name="c" select="')'"/>
784
+ </xsl:call-template>
785
+ </xsl:template>
786
+
787
+ <!-- 4.4.6.3 union -->
788
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:union]]">
789
+ <xsl:param name="p" select="0"/>
790
+ <xsl:call-template name="infix">
791
+ <xsl:with-param name="this-p" select="2"/>
792
+ <xsl:with-param name="p" select="$p"/>
793
+ <xsl:with-param name="mo"><mml:mo>&#8746;<!-- union --></mml:mo></xsl:with-param>
794
+ </xsl:call-template>
795
+ </xsl:template>
796
+
797
+ <!-- 4.4.6.4 intersect -->
798
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:intersect]]">
799
+ <xsl:param name="p" select="0"/>
800
+ <xsl:call-template name="infix">
801
+ <xsl:with-param name="this-p" select="3"/>
802
+ <xsl:with-param name="p" select="$p"/>
803
+ <xsl:with-param name="mo"><mml:mo>&#8745;<!-- intersect --></mml:mo></xsl:with-param>
804
+ </xsl:call-template>
805
+ </xsl:template>
806
+
807
+ <!-- 4.4.6.5 in -->
808
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:in]]">
809
+ <xsl:param name="p" select="0"/>
810
+ <xsl:call-template name="binary">
811
+ <xsl:with-param name="mo"><mml:mo>&#8712;<!-- in --></mml:mo></xsl:with-param>
812
+ <xsl:with-param name="p" select="$p"/>
813
+ <xsl:with-param name="this-p" select="3"/>
814
+ </xsl:call-template>
815
+ </xsl:template>
816
+
817
+ <!-- 4.4.6.5 notin -->
818
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:notin]]">
819
+ <xsl:param name="p" select="0"/>
820
+ <xsl:call-template name="binary">
821
+ <xsl:with-param name="mo"><mml:mo>&#8713;<!-- not in --></mml:mo></xsl:with-param>
822
+ <xsl:with-param name="p" select="$p"/>
823
+ <xsl:with-param name="this-p" select="3"/>
824
+ </xsl:call-template>
825
+ </xsl:template>
826
+
827
+ <!-- 4.4.6.7 subset -->
828
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:subset]]">
829
+ <xsl:param name="p" select="0"/>
830
+ <xsl:call-template name="infix">
831
+ <xsl:with-param name="this-p" select="2"/>
832
+ <xsl:with-param name="p" select="$p"/>
833
+ <xsl:with-param name="mo"><mml:mo>&#8838;<!-- subseteq --></mml:mo></xsl:with-param>
834
+ </xsl:call-template>
835
+ </xsl:template>
836
+
837
+ <!-- 4.4.6.8 prsubset -->
838
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:prsubset]]">
839
+ <xsl:param name="p" select="0"/>
840
+ <xsl:call-template name="infix">
841
+ <xsl:with-param name="this-p" select="2"/>
842
+ <xsl:with-param name="p" select="$p"/>
843
+ <xsl:with-param name="mo"><mml:mo>&#8834;<!-- prsubset --></mml:mo></xsl:with-param>
844
+ </xsl:call-template>
845
+ </xsl:template>
846
+
847
+ <!-- 4.4.6.9 notsubset -->
848
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:notsubset]]">
849
+ <xsl:param name="p" select="0"/>
850
+ <xsl:call-template name="binary">
851
+ <xsl:with-param name="this-p" select="2"/>
852
+ <xsl:with-param name="p" select="$p"/>
853
+ <xsl:with-param name="mo"><mml:mo>&#8840;<!-- notsubseteq --></mml:mo></xsl:with-param>
854
+ </xsl:call-template>
855
+ </xsl:template>
856
+
857
+ <!-- 4.4.6.10 notprsubset -->
858
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:notprsubset]]">
859
+ <xsl:param name="p" select="0"/>
860
+ <xsl:call-template name="binary">
861
+ <xsl:with-param name="this-p" select="2"/>
862
+ <xsl:with-param name="p" select="$p"/>
863
+ <xsl:with-param name="mo"><mml:mo>&#8836;<!-- prsubset --></mml:mo></xsl:with-param>
864
+ </xsl:call-template>
865
+ </xsl:template>
866
+
867
+ <!-- 4.4.6.11 setdiff -->
868
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:setdiff]]">
869
+ <xsl:param name="p" select="0"/>
870
+ <xsl:call-template name="binary">
871
+ <xsl:with-param name="this-p" select="2"/>
872
+ <xsl:with-param name="p" select="$p"/>
873
+ <xsl:with-param name="mo"><mml:mo>&#8726;<!-- setminus --></mml:mo></xsl:with-param>
874
+ </xsl:call-template>
875
+ </xsl:template>
876
+
877
+ <!-- 4.4.6.12 card -->
878
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:card]]">
879
+ <mml:mrow>
880
+ <mml:mo>|</mml:mo>
881
+ <xsl:apply-templates mode="c2p" select="*[2]"/>
882
+ <mml:mo>|</mml:mo>
883
+ </mml:mrow>
884
+ </xsl:template>
885
+
886
+ <!-- 4.4.6.13 cartesianproduct -->
887
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:cartesianproduct or self::mml:vectorproduct]]">
888
+ <xsl:param name="p" select="0"/>
889
+ <xsl:call-template name="infix">
890
+ <xsl:with-param name="this-p" select="2"/>
891
+ <xsl:with-param name="p" select="$p"/>
892
+ <xsl:with-param name="mo"><mml:mo>&#215;<!-- times --></mml:mo></xsl:with-param>
893
+ </xsl:call-template>
894
+ </xsl:template>
895
+
896
+ <xsl:template
897
+ match="mml:apply[*[1][self::mml:cartesianproduct][count(following-sibling::mml:reals)=count(following-sibling::*)]]"
898
+ priority="2">
899
+ <mml:msup>
900
+ <xsl:apply-templates mode="c2p" select="*[2]">
901
+ <xsl:with-param name="p" select="5"/>
902
+ </xsl:apply-templates>
903
+ <mml:mn><xsl:value-of select="count(*)-1"/></mml:mn>
904
+ </mml:msup>
905
+ </xsl:template>
906
+
907
+
908
+ <!-- 4.4.7.1 sum -->
909
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:sum]]">
910
+ <mml:mrow>
911
+ <mml:msubsup>
912
+ <mml:mo>&#8721;<!--sum--></mml:mo>
913
+ <mml:mrow><xsl:apply-templates mode="c2p" select="mml:lowlimit/*|mml:interval/*[1]|mml:condition/*"/></mml:mrow>
914
+ <mml:mrow><xsl:apply-templates mode="c2p" select="mml:uplimit/*|mml:interval/*[2]"/></mml:mrow>
915
+ </mml:msubsup>
916
+ <xsl:apply-templates mode="c2p" select="*[last()]"/>
917
+ </mml:mrow>
918
+ </xsl:template>
919
+
920
+ <!-- 4.4.7.2 product -->
921
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:product]]">
922
+ <mml:mrow>
923
+ <mml:msubsup>
924
+ <mml:mo>&#8719;<!--product--></mml:mo>
925
+ <mml:mrow><xsl:apply-templates mode="c2p" select="mml:lowlimit/*|mml:interval/*[1]|mml:condition/*"/></mml:mrow>
926
+ <mml:mrow><xsl:apply-templates mode="c2p" select="mml:uplimit/*|mml:interval/*[2]"/></mml:mrow>
927
+ </mml:msubsup>
928
+ <xsl:apply-templates mode="c2p" select="*[last()]"/>
929
+ </mml:mrow>
930
+ </xsl:template>
931
+
932
+ <!-- 4.4.7.3 limit -->
933
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:limit]]">
934
+ <mml:mrow>
935
+ <mml:munder>
936
+ <mml:mi>limit</mml:mi>
937
+ <mml:mrow><xsl:apply-templates mode="c2p" select="mml:lowlimit|mml:condition/*"/></mml:mrow>
938
+ </mml:munder>
939
+ <xsl:apply-templates mode="c2p" select="*[last()]"/>
940
+ </mml:mrow>
941
+ </xsl:template>
942
+
943
+ <xsl:template mode="c2p" match="mml:apply[mml:limit]/mml:lowlimit" priority="3">
944
+ <mml:mrow>
945
+ <xsl:apply-templates mode="c2p" select="../mml:bvar/node()"/>
946
+ <mml:mo>&#8594;<!--rightarrow--></mml:mo>
947
+ <xsl:apply-templates mode="c2p"/>
948
+ </mml:mrow>
949
+ </xsl:template>
950
+
951
+
952
+ <!-- 4.4.7.4 tendsto -->
953
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:tendsto]]">
954
+ <xsl:param name="p"/>
955
+ <xsl:call-template name="binary">
956
+ <xsl:with-param name="this-p" select="2"/>
957
+ <xsl:with-param name="p" select="$p"/>
958
+ <xsl:with-param name="mo"><mml:mo>
959
+ <xsl:choose>
960
+ <xsl:when test="@type='above'">&#8600;<!--searrow--></xsl:when>
961
+ <xsl:when test="@type='below'">&#8599;<!--nearrow--></xsl:when>
962
+ <xsl:when test="@type='two-sided'">&#8594;<!--rightarrow--></xsl:when>
963
+ <xsl:otherwise>&#8594;<!--rightarrow--></xsl:otherwise>
964
+ </xsl:choose>
965
+ </mml:mo></xsl:with-param>
966
+ </xsl:call-template>
967
+ </xsl:template>
968
+
969
+ <!-- 4.4.8.1 trig -->
970
+ <xsl:template mode="c2p" match="mml:apply[*[1][
971
+ self::mml:sin or self::mml:cos or self::mml:tan or self::mml:sec or
972
+ self::mml:csc or self::mml:cot or self::mml:sinh or self::mml:cosh or
973
+ self::mml:tanh or self::mml:sech or self::mml:csch or self::mml:coth or
974
+ self::mml:arcsin or self::mml:arccos or self::mml:arctan or self::mml:arccosh
975
+ or self::mml:arccot or self::mml:arccoth or self::mml:arccsc or
976
+ self::mml:arccsch or self::mml:arcsec or self::mml:arcsech or
977
+ self::mml:arcsinh or self::mml:arctanh or self::mml:ln]]">
978
+ <mml:mrow>
979
+ <mml:mi><xsl:value-of select="local-name(*[1])"/></mml:mi>
980
+ <xsl:apply-templates mode="c2p" select="*[2]">
981
+ <xsl:with-param name="p" select="7"/>
982
+ </xsl:apply-templates>
983
+ </mml:mrow>
984
+ </xsl:template>
985
+
986
+
987
+
988
+
989
+ <!-- 4.4.8.2 exp -->
990
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:exp]]">
991
+ <mml:msup>
992
+ <mml:mi>e<!-- exponential e--></mml:mi>
993
+ <mml:mrow><xsl:apply-templates mode="c2p" select="*[2]"/></mml:mrow>
994
+ </mml:msup>
995
+ </xsl:template>
996
+
997
+ <!-- 4.4.8.3 ln -->
998
+ <!-- with trig -->
999
+
1000
+ <!-- 4.4.8.4 log -->
1001
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:log]]">
1002
+ <mml:mrow>
1003
+ <xsl:choose>
1004
+ <xsl:when test="not(mml:logbase) or mml:logbase=10">
1005
+ <mml:mi>log</mml:mi>
1006
+ </xsl:when>
1007
+ <xsl:otherwise>
1008
+ <mml:msub>
1009
+ <mml:mi>log</mml:mi>
1010
+ <mml:mrow><xsl:apply-templates mode="c2p" select="mml:logbase/node()"/></mml:mrow>
1011
+ </mml:msub>
1012
+ </xsl:otherwise>
1013
+ </xsl:choose>
1014
+ <xsl:apply-templates mode="c2p" select="*[last()]">
1015
+ <xsl:with-param name="p" select="7"/>
1016
+ </xsl:apply-templates>
1017
+ </mml:mrow>
1018
+ </xsl:template>
1019
+
1020
+
1021
+ <!-- 4.4.9.1 mean -->
1022
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:mean]]">
1023
+ <mml:mrow>
1024
+ <mml:mo>&#9001;<!--langle--></mml:mo>
1025
+ <xsl:for-each select="*[position()&gt;1]">
1026
+ <xsl:apply-templates mode="c2p" select="."/>
1027
+ <xsl:if test="position() !=last()"><mml:mo>,</mml:mo></xsl:if>
1028
+ </xsl:for-each>
1029
+ <mml:mo>&#9002;<!--rangle--></mml:mo>
1030
+ </mml:mrow>
1031
+ </xsl:template>
1032
+
1033
+
1034
+ <!-- 4.4.9.2 sdef -->
1035
+ <xsl:template mode="c2p" match="mml:sdev">
1036
+ <mml:mo>&#963;<!--sigma--></mml:mo>
1037
+ </xsl:template>
1038
+
1039
+ <!-- 4.4.9.3 variance -->
1040
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:variance]]">
1041
+ <mml:msup>
1042
+ <mml:mrow>
1043
+ <mml:mo>&#963;<!--sigma--></mml:mo>
1044
+ <mml:mo>(</mml:mo>
1045
+ <xsl:apply-templates mode="c2p" select="*[2]"/>
1046
+ <mml:mo>)</mml:mo>
1047
+ </mml:mrow>
1048
+ <mml:mn>2</mml:mn>
1049
+ </mml:msup>
1050
+ </xsl:template>
1051
+
1052
+
1053
+ <!-- 4.4.9.4 median -->
1054
+ <xsl:template mode="c2p" match="mml:median">
1055
+ <mml:mo>median</mml:mo>
1056
+ </xsl:template>
1057
+
1058
+
1059
+ <!-- 4.4.9.5 mode -->
1060
+ <xsl:template mode="c2p" match="mml:mode">
1061
+ <mml:mo>mode</mml:mo>
1062
+ </xsl:template>
1063
+
1064
+ <!-- 4.4.9.5 moment -->
1065
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:moment]]">
1066
+ <mml:mrow>
1067
+ <mml:mo>&#9001;<!--langle--></mml:mo>
1068
+ <mml:msup>
1069
+ <xsl:apply-templates mode="c2p" select="*[last()]"/>
1070
+ <mml:mrow><xsl:apply-templates mode="c2p" select="mml:degree/node()"/></mml:mrow>
1071
+ </mml:msup>
1072
+ <mml:mo>&#9002;<!--rangle--></mml:mo>
1073
+ </mml:mrow>
1074
+ </xsl:template>
1075
+
1076
+ <!-- 4.4.9.5 momentabout -->
1077
+ <xsl:template mode="c2p" match="mml:momentabout"/>
1078
+
1079
+ <!-- 4.4.10.1 vector -->
1080
+ <xsl:template mode="c2p" match="mml:vector">
1081
+ <mml:mrow>
1082
+ <mml:mo>(</mml:mo>
1083
+ <mml:mtable>
1084
+ <xsl:for-each select="*">
1085
+ <mml:mtr><mml:mtd><xsl:apply-templates mode="c2p" select="."/></mml:mtd></mml:mtr>
1086
+ </xsl:for-each>
1087
+ </mml:mtable>
1088
+ <mml:mo>)</mml:mo>
1089
+ </mml:mrow>
1090
+ </xsl:template>
1091
+
1092
+ <!-- 4.4.10.2 matrix -->
1093
+ <xsl:template mode="c2p" match="mml:matrix">
1094
+ <mml:mrow>
1095
+ <mml:mo>(</mml:mo>
1096
+ <mml:mtable>
1097
+ <xsl:apply-templates mode="c2p"/>
1098
+ </mml:mtable>
1099
+ <mml:mo>)</mml:mo>
1100
+ </mml:mrow>
1101
+ </xsl:template>
1102
+
1103
+ <!-- 4.4.10.3 matrixrow -->
1104
+ <xsl:template mode="c2p" match="mml:matrixrow">
1105
+ <mml:mtr>
1106
+ <xsl:for-each select="*">
1107
+ <mml:mtd><xsl:apply-templates mode="c2p" select="."/></mml:mtd>
1108
+ </xsl:for-each>
1109
+ </mml:mtr>
1110
+ </xsl:template>
1111
+
1112
+ <!-- 4.4.10.4 determinant -->
1113
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:determinant]]">
1114
+ <mml:mrow>
1115
+ <mml:mi>det</mml:mi>
1116
+ <xsl:apply-templates mode="c2p" select="*[2]">
1117
+ <xsl:with-param name="p" select="7"/>
1118
+ </xsl:apply-templates>
1119
+ </mml:mrow>
1120
+ </xsl:template>
1121
+
1122
+ <xsl:template
1123
+ match="mml:apply[*[1][self::mml:determinant]][*[2][self::mml:matrix]]" priority="2">
1124
+ <mml:mrow>
1125
+ <mml:mo>|</mml:mo>
1126
+ <mml:mtable>
1127
+ <xsl:apply-templates mode="c2p" select="mml:matrix/*"/>
1128
+ </mml:mtable>
1129
+ <mml:mo>|</mml:mo>
1130
+ </mml:mrow>
1131
+ </xsl:template>
1132
+
1133
+ <!-- 4.4.10.5 transpose -->
1134
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:transpose]]">
1135
+ <mml:msup>
1136
+ <xsl:apply-templates mode="c2p" select="*[2]">
1137
+ <xsl:with-param name="p" select="7"/>
1138
+ </xsl:apply-templates>
1139
+ <mml:mi>T</mml:mi>
1140
+ </mml:msup>
1141
+ </xsl:template>
1142
+
1143
+ <!-- 4.4.10.5 selector -->
1144
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:selector]]">
1145
+ <mml:msub>
1146
+ <xsl:apply-templates mode="c2p" select="*[2]">
1147
+ <xsl:with-param name="p" select="7"/>
1148
+ </xsl:apply-templates>
1149
+ <mml:mrow>
1150
+ <xsl:for-each select="*[position()&gt;2]">
1151
+ <xsl:apply-templates mode="c2p" select="."/>
1152
+ <xsl:if test="position() !=last()"><mml:mo>,</mml:mo></xsl:if>
1153
+ </xsl:for-each>
1154
+ </mml:mrow>
1155
+ </mml:msub>
1156
+ </xsl:template>
1157
+
1158
+ <!-- *** -->
1159
+ <!-- 4.4.10.6 vectorproduct see cartesianproduct -->
1160
+
1161
+
1162
+ <!-- 4.4.10.7 scalarproduct-->
1163
+ <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:scalarproduct or self::mml:outerproduct]]">
1164
+ <xsl:param name="p" select="0"/>
1165
+ <xsl:call-template name="infix">
1166
+ <xsl:with-param name="this-p" select="2"/>
1167
+ <xsl:with-param name="p" select="$p"/>
1168
+ <xsl:with-param name="mo"><mml:mo>.</mml:mo></xsl:with-param>
1169
+ </xsl:call-template>
1170
+ </xsl:template>
1171
+
1172
+ <!-- 4.4.10.8 outerproduct-->
1173
+
1174
+ <!-- 4.4.11.2 semantics -->
1175
+ <xsl:template mode="c2p" match="mml:semantics">
1176
+ <xsl:apply-templates mode="c2p" select="*[1]"/>
1177
+ </xsl:template>
1178
+ <xsl:template mode="c2p" match="mml:semantics[mml:annotation-xml/@encoding='MathML-Presentation']">
1179
+ <xsl:apply-templates mode="c2p" select="mml:annotation-xml[@encoding='MathML-Presentation']/node()"/>
1180
+ </xsl:template>
1181
+
1182
+ <!-- 4.4.12.1 integers -->
1183
+ <xsl:template mode="c2p" match="mml:integers">
1184
+ <mml:mi mathvariant="double-struck">Z</mml:mi>
1185
+ </xsl:template>
1186
+
1187
+ <!-- 4.4.12.2 reals -->
1188
+ <xsl:template mode="c2p" match="mml:reals">
1189
+ <mml:mi mathvariant="double-struck">R</mml:mi>
1190
+ </xsl:template>
1191
+
1192
+ <!-- 4.4.12.3 rationals -->
1193
+ <xsl:template mode="c2p" match="mml:rationals">
1194
+ <mml:mi mathvariant="double-struck">Q</mml:mi>
1195
+ </xsl:template>
1196
+
1197
+ <!-- 4.4.12.4 naturalnumbers -->
1198
+ <xsl:template mode="c2p" match="mml:naturalnumbers">
1199
+ <mml:mi mathvariant="double-struck">N</mml:mi>
1200
+ </xsl:template>
1201
+
1202
+ <!-- 4.4.12.5 complexes -->
1203
+ <xsl:template mode="c2p" match="mml:complexes">
1204
+ <mml:mi mathvariant="double-struck">C</mml:mi>
1205
+ </xsl:template>
1206
+
1207
+ <!-- 4.4.12.6 primes -->
1208
+ <xsl:template mode="c2p" match="mml:primes">
1209
+ <mml:mi mathvariant="double-struck">P</mml:mi>
1210
+ </xsl:template>
1211
+
1212
+ <!-- 4.4.12.7 exponentiale -->
1213
+ <xsl:template mode="c2p" match="mml:exponentiale">
1214
+ <mml:mi>e<!-- exponential e--></mml:mi>
1215
+ </xsl:template>
1216
+
1217
+ <!-- 4.4.12.8 imaginaryi -->
1218
+ <xsl:template mode="c2p" match="mml:imaginaryi">
1219
+ <mml:mi>i<!-- imaginary i--></mml:mi>
1220
+ </xsl:template>
1221
+
1222
+ <!-- 4.4.12.9 notanumber -->
1223
+ <xsl:template mode="c2p" match="mml:notanumber">
1224
+ <mml:mi>NaN</mml:mi>
1225
+ </xsl:template>
1226
+
1227
+ <!-- 4.4.12.10 true -->
1228
+ <xsl:template mode="c2p" match="mml:true">
1229
+ <mml:mi>true</mml:mi>
1230
+ </xsl:template>
1231
+
1232
+ <!-- 4.4.12.11 false -->
1233
+ <xsl:template mode="c2p" match="mml:false">
1234
+ <mml:mi>false</mml:mi>
1235
+ </xsl:template>
1236
+
1237
+ <!-- 4.4.12.12 emptyset -->
1238
+ <xsl:template mode="c2p" match="mml:emptyset">
1239
+ <mml:mi>&#8709;<!-- emptyset --></mml:mi>
1240
+ </xsl:template>
1241
+
1242
+
1243
+ <!-- 4.4.12.13 pi -->
1244
+ <xsl:template mode="c2p" match="mml:pi">
1245
+ <mml:mi>&#960;<!-- pi --></mml:mi>
1246
+ </xsl:template>
1247
+
1248
+ <!-- 4.4.12.14 eulergamma -->
1249
+ <xsl:template mode="c2p" match="mml:eulergamma">
1250
+ <mml:mi>&#947;<!-- gamma --></mml:mi>
1251
+ </xsl:template>
1252
+
1253
+ <!-- 4.4.12.15 infinity -->
1254
+ <xsl:template mode="c2p" match="mml:infinity">
1255
+ <mml:mi>&#8734;<!-- infinity --></mml:mi>
1256
+ </xsl:template>
1257
+
1258
+
1259
+ <!-- ****************************** -->
1260
+ <xsl:template name="infix" >
1261
+ <xsl:param name="mo"/>
1262
+ <xsl:param name="p" select="0"/>
1263
+ <xsl:param name="this-p" select="0"/>
1264
+ <mml:mrow>
1265
+ <xsl:if test="$this-p &lt; $p"><mml:mo>(</mml:mo></xsl:if>
1266
+ <xsl:for-each select="*[position()&gt;1]">
1267
+ <xsl:if test="position() &gt; 1">
1268
+ <xsl:copy-of select="$mo"/>
1269
+ </xsl:if>
1270
+ <xsl:apply-templates mode="c2p" select=".">
1271
+ <xsl:with-param name="p" select="$this-p"/>
1272
+ </xsl:apply-templates>
1273
+ </xsl:for-each>
1274
+ <xsl:if test="$this-p &lt; $p"><mml:mo>)</mml:mo></xsl:if>
1275
+ </mml:mrow>
1276
+ </xsl:template>
1277
+
1278
+ <xsl:template name="binary" >
1279
+ <xsl:param name="mo"/>
1280
+ <xsl:param name="p" select="0"/>
1281
+ <xsl:param name="this-p" select="0"/>
1282
+ <mml:mrow>
1283
+ <xsl:if test="$this-p &lt; $p"><mml:mo>(</mml:mo></xsl:if>
1284
+ <xsl:apply-templates mode="c2p" select="*[2]">
1285
+ <xsl:with-param name="p" select="$this-p"/>
1286
+ </xsl:apply-templates>
1287
+ <xsl:copy-of select="$mo"/>
1288
+ <xsl:apply-templates mode="c2p" select="*[3]">
1289
+ <xsl:with-param name="p" select="$this-p"/>
1290
+ </xsl:apply-templates>
1291
+ <xsl:if test="$this-p &lt; $p"><mml:mo>)</mml:mo></xsl:if>
1292
+ </mml:mrow>
1293
+ </xsl:template>
1294
+
1295
+ <xsl:template name="set" >
1296
+ <xsl:param name="o" select="'{'"/>
1297
+ <xsl:param name="c" select="'}'"/>
1298
+ <mml:mrow>
1299
+ <mml:mo><xsl:value-of select="$o"/></mml:mo>
1300
+ <xsl:choose>
1301
+ <xsl:when test="mml:condition">
1302
+ <mml:mrow><xsl:apply-templates mode="c2p" select="mml:bvar/*[not(self::bvar or self::condition)]"/></mml:mrow>
1303
+ <mml:mo>|</mml:mo>
1304
+ <mml:mrow><xsl:apply-templates mode="c2p" select="mml:condition/node()"/></mml:mrow>
1305
+ </xsl:when>
1306
+ <xsl:otherwise>
1307
+ <xsl:for-each select="*">
1308
+ <xsl:apply-templates mode="c2p" select="."/>
1309
+ <xsl:if test="position() !=last()"><mml:mo>,</mml:mo></xsl:if>
1310
+ </xsl:for-each>
1311
+ </xsl:otherwise>
1312
+ </xsl:choose>
1313
+ <mml:mo><xsl:value-of select="$c"/></mml:mo>
1314
+ </mml:mrow>
1315
+ </xsl:template>
1316
+
1317
+ </xsl:stylesheet>
1318
+