Statistics
| Revision:

root / tmp / org.txm.core / res / org / txm / xml / xsl / tei / docx / utils / maths / omml2mml.xsl @ 187

History | View | Annotate | Download (85.6 kB)

1
<?xml version="1.0" encoding="utf-8"?>
2
<!-- Beta Version 070708 -->
3
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4
		xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
5
		xmlns="http://www.w3.org/1998/Math/MathML"
6
		xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math"
7
		version="2.0"
8
                exclude-result-prefixes="m w">
9
	<!-- %% Global Definitions -->
10

    
11
	<!-- Every single unicode character that is recognized by OMML as an operator -->
12
	<xsl:variable name="sOperators"
13
                 select="concat(      '!&#34;#&amp;()+,-./:',           ';&lt;=&gt;?@[\]^_{',           '|}~¡¦¬¯°±²³·¹¿',           '×÷̀́̂̃̄̅̆̇̈̉',           '̊̋̌̍̎̏̐̑̒̓̔̕',           '̡̛̖̗̘̙̜̝̞̟̠̚',           '̢̧̨̣̤̥̦̩̪̫̬̭',           '̴̵̶̷̸̮̯̰̱̲̳̿',           '         ‐‒–',           '—‖†‡•․‥…′″‴‼',           '⁀⁄⁎⁏⁐⁗⁡⁢⁣⁰⁴⁵',           '⁶⁷⁸⁹⁺⁻⁼⁽⁾₀₁₂',           '₃₄₅₆₇₈₉₊₋₌₍₎',           '⃒⃓⃘⃙⃚⃐⃑⃔⃕⃖⃗⃛',           '⃜⃝⃞⃟⃠⃡⃤⃥⃦⃨⃧⃩',           '⃪⅀ࡢ←↑→↓↔↕↖↗↘↙',           '↚↛↜↝↞↟↠↡↢↣↤↥',           '↦↧↨↩↪↫↬↭↮↯↰↱',           '↲↳↶↷↺↻↼↽↾↿⇀⇁',           '⇂⇃⇄⇅⇆⇇⇈⇉⇊⇋⇌⇍',           '⇎⇏⇐⇑⇒⇓⇔⇕⇖⇗⇘⇙',           '⇚⇛⇜⇝⇞⇟⇠⇡⇢⇣⇤⇥',           '⇦⇧⇨⇩⇳⇴⇵⇶⇷⇸⇹⇺',           '⇻⇼⇽⇾⇿∀∁∂∃∄∆∇',           '∈∉∊∋∌∍∏∐∑−∓∔',           '∕∖∗∘∙√∛∜∝∣∤∥',           '∦∧∨∩∪∫∬∭∮∯∰∱',           '∲∳∴∵∶∷∸∹∺∻∼∽',           '∾≀≁≂≃≄≅≆≇≈≉≊',           '≋≌≍≎≏≐≑≒≓≔≕≖',           '≗≘≙≚≛≜≝≞≟≠≡≢',           '≣≤≥≦≧≨≩≪≫≬≭≮',           '≯≰≱≲≳≴≵≶≷≸≹≺',           '≻≼≽≾≿⊀⊁⊂⊃⊄⊅⊆',           '⊇⊈⊉⊊⊋⊌⊍⊎⊏⊐⊑⊒',           '⊓⊔⊕⊖⊗⊘⊙⊚⊛⊜⊝⊞',           '⊟⊠⊡⊢⊣⊥⊦⊧⊨⊩⊪⊫',           '⊬⊭⊮⊯⊰⊱⊲⊳⊴⊵⊶⊷',           '⊸⊹⊺⊻⊼⊽⋀⋁⋂⋃⋄⋅',           '⋆⋇⋈⋉⋊⋋⋌⋍⋎⋏⋐⋑',           '⋒⋓⋔⋕⋖⋗⋘⋙⋚⋛⋜⋝',           '⋞⋟⋠⋡⋢⋣⋤⋥⋦⋧⋨⋩',           '⋪⋫⋬⋭⋮⋯⋰⋱⋲⋳⋴⋵',           '⋶⋷⋸⋹⋺⋻⋼⋽⋾⋿⌅⌆',           '⌈⌉⌊⌋⌜⌝⌞⌟⌢⌣〈〉',           '⌽⌿⎰⎱⏜⏝⏞⏟⏠│├┤',           '┬┴▁█▒■□▭▲△▴▵',           '▶▷▸▹▼▽▾▿◀◁◂◃',           '◄◅◊○◦◫◬◸◹◺◻◼',           '◽◾◿★☆❲❳⟑⟒⟓⟔⟕',           '⟖⟗⟘⟙⟚⟛⟜⟝⟞⟟⟠⟡',           '⟢⟣⟤⟥⟦⟧⟨⟩⟪⟫⟰⟱',           '⟲⟳⟴⟵⟶⟷⟸⟹⟺⟻⟼⟽',           '⟾⟿⤀⤁⤂⤃⤄⤅⤆⤇⤈⤉',           '⤊⤋⤌⤍⤎⤏⤐⤑⤒⤓⤔⤕',           '⤖⤗⤘⤙⤚⤛⤜⤝⤞⤟⤠⤡',           '⤢⤣⤤⤥⤦⤧⤨⤩⤪⤫⤬⤭',           '⤮⤯⤰⤱⤲⤳⤴⤵⤶⤷⤸⤹',           '⤺⤻⤼⤽⤾⤿⥀⥁⥂⥃⥄⥅',           '⥆⥇⥈⥉⥊⥋⥌⥍⥎⥏⥐⥑',           '⥒⥓⥔⥕⥖⥗⥘⥙⥚⥛⥜⥝',           '⥞⥟⥠⥡⥢⥣⥤⥥⥦⥧⥨⥩',           '⥪⥫⥬⥭⥮⥯⥰⥱⥲⥳⥴⥵',           '⥶⥷⥸⥹⥺⥻⥼⥽⥾⥿⦀⦂',           '⦃⦄⦅⦆⦇⦈⦉⦊⦋⦌⦍⦎',           '⦏⦐⦑⦒⦓⦔⦕⦖⦗⦘⦙⦚',           '⦶⦷⦸⦹⧀⧁⧄⧅⧆⧇⧈⧎',           '⧏⧐⧑⧒⧓⧔⧕⧖⧗⧘⧙⧚',           '⧛⧟⧡⧢⧣⧤⧥⧦⧫⧴⧵⧶',           '⧷⧸⧹⧺⧻⧼⧽⧾⧿⨀⨁⨂',           '⨃⨄⨅⨆⨇⨈⨉⨊⨋⨌⨍⨎',           '⨏⨐⨑⨒⨓⨔⨕⨖⨗⨘⨙⨚',           '⨛⨜⨝⨞⨟⨠⨡⨢⨣⨤⨥⨦',           '⨧⨨⨩⨪⨫⨬⨭⨮⨯⨰⨱⨲',           '⨳⨴⨵⨶⨷⨸⨹⨺⨻⨼⨽⨾',           '⨿⩀⩁⩂⩃⩄⩅⩆⩇⩈⩉⩊',           '⩋⩌⩍⩎⩏⩐⩑⩒⩓⩔⩕⩖',           '⩗⩘⩙⩚⩛⩜⩝⩞⩟⩠⩡⩢',           '⩣⩤⩥⩦⩧⩨⩩⩪⩫⩬⩭⩮',           '⩯⩰⩱⩲⩳⩴⩵⩶⩷⩸⩹⩺',           '⩻⩼⩽⩾⩿⪀⪁⪂⪃⪄⪅⪆',           '⪇⪈⪉⪊⪋⪌⪍⪎⪏⪐⪑⪒',           '⪓⪔⪕⪖⪗⪘⪙⪚⪛⪜⪝⪞',           '⪟⪠⪡⪢⪣⪤⪥⪦⪧⪨⪩⪪',           '⪫⪬⪭⪮⪯⪰⪱⪲⪳⪴⪵⪶',           '⪷⪸⪹⪺⪻⪼⪽⪾⪿⫀⫁⫂',           '⫃⫄⫅⫆⫇⫈⫉⫊⫋⫌⫍⫎',           '⫏⫐⫑⫒⫓⫔⫕⫖⫗⫘⫙⫚',           '⫛⫝̸⫝⫞⫟⫠⫢⫣⫤⫥⫦⫧',           '⫨⫩⫪⫫⫬⫭⫮⫯⫰⫲⫳⫴',           '⫵⫶⫷⫸⫹⫺⫻⫼⫽⫾⫿⬄',           '⬆⬇⬌⬍〔〕〖〗〘〙!&',           '()+,-./:;<=>',           '?@[\]^_{|}')"/>
14

    
15
	  <!-- A string of '-'s repeated exactly as many times as the operators above -->
16
	<xsl:variable name="sMinuses">
17
		    <xsl:call-template name="SRepeatChar">
18
			      <xsl:with-param name="cchRequired" select="string-length($sOperators)"/>
19
			      <xsl:with-param name="ch" select="'-'"/>
20
		    </xsl:call-template>
21
	  </xsl:variable>
22

    
23
	  <!-- Every single unicode character that is recognized by OMML as a number -->
24
	<xsl:variable name="sNumbers" select="'0123456789'"/>
25

    
26
	  <!-- A string of '0's repeated exactly as many times as the list of numbers above -->
27
	<xsl:variable name="sZeros">
28
		    <xsl:call-template name="SRepeatChar">
29
			      <xsl:with-param name="cchRequired" select="string-length($sNumbers)"/>
30
			      <xsl:with-param name="ch" select="'0'"/>
31
		    </xsl:call-template>
32
	  </xsl:variable>
33

    
34
	  <!-- %%Template: SReplace
35

    
36
		Replace all occurences of sOrig in sInput with sReplacement
37
		and return the resulting string. -->
38
	<xsl:template name="SReplace">
39
		    <xsl:param name="sInput"/>
40
		    <xsl:param name="sOrig"/>
41
		    <xsl:param name="sReplacement"/>
42

    
43
		    <xsl:choose>
44
			      <xsl:when test="not(contains($sInput, $sOrig))">
45
				        <xsl:value-of select="$sInput"/>
46
			      </xsl:when>
47
			      <xsl:otherwise>
48
				        <xsl:variable name="sBefore" select="substring-before($sInput, $sOrig)"/>
49
				        <xsl:variable name="sAfter" select="substring-after($sInput, $sOrig)"/>
50
				        <xsl:variable name="sAfterProcessed">
51
					          <xsl:call-template name="SReplace">
52
						            <xsl:with-param name="sInput" select="$sAfter"/>
53
						            <xsl:with-param name="sOrig" select="$sOrig"/>
54
						            <xsl:with-param name="sReplacement" select="$sReplacement"/>
55
					          </xsl:call-template>
56
				        </xsl:variable>
57

    
58
				        <xsl:value-of select="concat($sBefore, concat($sReplacement, $sAfterProcessed))"/>
59
			      </xsl:otherwise>
60
		    </xsl:choose>
61
	  </xsl:template>
62

    
63
	  <!-- Templates -->
64
	<!--
65
	    <xsl:template match="/">
66
	    <math>
67
	    <xsl:apply-templates select="*" />
68
	    </math>
69
	</xsl:template>
70
	-->
71
	<xsl:template match="m:borderBox">
72

    
73
		<!-- Get Lowercase versions of properties -->
74
		<xsl:variable name="sLowerCaseHideTop"
75
                    select="translate(m:borderBoxPr[last()]/m:hideTop[last()]/@m:val, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',                                                                 'abcdefghijklmnopqrstuvwxyz')"/>
76
		    <xsl:variable name="sLowerCaseHideBot"
77
                    select="translate(m:borderBoxPr[last()]/m:hideBot[last()]/@m:val, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',                                                                 'abcdefghijklmnopqrstuvwxyz')"/>
78
		    <xsl:variable name="sLowerCaseHideLeft"
79
                    select="translate(m:borderBoxPr[last()]/m:hideLeft[last()]/@m:val, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',                                                                 'abcdefghijklmnopqrstuvwxyz')"/>
80
		    <xsl:variable name="sLowerCaseHideRight"
81
                    select="translate(m:borderBoxPr[last()]/m:hideRight[last()]/@m:val, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',                                                                 'abcdefghijklmnopqrstuvwxyz')"/>
82
		    <xsl:variable name="sLowerCaseStrikeH"
83
                    select="translate(m:borderBoxPr[last()]/m:strikeH[last()]/@m:val, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',                                                                 'abcdefghijklmnopqrstuvwxyz')"/>
84
		    <xsl:variable name="sLowerCaseStrikeV"
85
                    select="translate(m:borderBoxPr[last()]/m:strikeV[last()]/@m:val, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',                                                                 'abcdefghijklmnopqrstuvwxyz')"/>
86
		    <xsl:variable name="sLowerCaseStrikeBLTR"
87
                    select="translate(m:borderBoxPr[last()]/m:strikeBLTR[last()]/@m:val, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',                                                                 'abcdefghijklmnopqrstuvwxyz')"/>
88
		    <xsl:variable name="sLowerCaseStrikeTLBR"
89
                    select="translate(m:borderBoxPr[last()]/m:strikeTLBR[last()]/@m:val, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',                                                                 'abcdefghijklmnopqrstuvwxyz')"/>
90
		    <xsl:variable name="fHideTop">
91
			      <xsl:choose>
92
				        <xsl:when test="$sLowerCaseHideTop='on'">
93
					          <xsl:text>1</xsl:text>
94
				        </xsl:when>
95
				        <xsl:otherwise>
96
					          <xsl:text>0</xsl:text>
97
				        </xsl:otherwise>
98
			      </xsl:choose>
99
		    </xsl:variable>
100
		    <xsl:variable name="fHideBot">
101
			      <xsl:choose>
102
				        <xsl:when test="$sLowerCaseHideBot='on'">
103
					          <xsl:text>1</xsl:text>
104
				        </xsl:when>
105
				        <xsl:otherwise>
106
					          <xsl:text>0</xsl:text>
107
				        </xsl:otherwise>
108
			      </xsl:choose>
109
		    </xsl:variable>
110
		    <xsl:variable name="fHideLeft">
111
			      <xsl:choose>
112
				        <xsl:when test="$sLowerCaseHideLeft='on'">
113
					          <xsl:text>1</xsl:text>
114
				        </xsl:when>
115
				        <xsl:otherwise>
116
					          <xsl:text>0</xsl:text>
117
				        </xsl:otherwise>
118
			      </xsl:choose>
119
		    </xsl:variable>
120
		    <xsl:variable name="fHideRight">
121
			      <xsl:choose>
122
				        <xsl:when test="$sLowerCaseHideRight='on'">
123
					          <xsl:text>1</xsl:text>
124
				        </xsl:when>
125
				        <xsl:otherwise>
126
					          <xsl:text>0</xsl:text>
127
				        </xsl:otherwise>
128
			      </xsl:choose>
129
		    </xsl:variable>
130
		    <xsl:variable name="fStrikeH">
131
			      <xsl:choose>
132
				        <xsl:when test="$sLowerCaseStrikeH='on'">
133
					          <xsl:text>1</xsl:text>
134
				        </xsl:when>
135
				        <xsl:otherwise>
136
					          <xsl:text>0</xsl:text>
137
				        </xsl:otherwise>
138
			      </xsl:choose>
139
		    </xsl:variable>
140
		    <xsl:variable name="fStrikeV">
141
			      <xsl:choose>
142
				        <xsl:when test="$sLowerCaseStrikeV='on'">
143
					          <xsl:text>1</xsl:text>
144
				        </xsl:when>
145
				        <xsl:otherwise>
146
					          <xsl:text>0</xsl:text>
147
				        </xsl:otherwise>
148
			      </xsl:choose>
149
		    </xsl:variable>
150
		    <xsl:variable name="fStrikeBLTR">
151
			      <xsl:choose>
152
				        <xsl:when test="$sLowerCaseStrikeBLTR='on'">
153
					          <xsl:text>1</xsl:text>
154
				        </xsl:when>
155
				        <xsl:otherwise>
156
					          <xsl:text>0</xsl:text>
157
				        </xsl:otherwise>
158
			      </xsl:choose>
159
		    </xsl:variable>
160
		    <xsl:variable name="fStrikeTLBR">
161
			      <xsl:choose>
162
				        <xsl:when test="$sLowerCaseStrikeTLBR='on'">
163
					          <xsl:text>1</xsl:text>
164
				        </xsl:when>
165
				        <xsl:otherwise>
166
					          <xsl:text>0</xsl:text>
167
				        </xsl:otherwise>
168
			      </xsl:choose>
169
		    </xsl:variable>
170

    
171
		    <menclose>
172
			      <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
173
				        <xsl:with-param name="fHideTop" select="$fHideTop"/>
174
				        <xsl:with-param name="fHideBot" select="$fHideBot"/>
175
				        <xsl:with-param name="fHideLeft" select="$fHideLeft"/>
176
				        <xsl:with-param name="fHideRight" select="$fHideRight"/>
177
				        <xsl:with-param name="fStrikeH" select="$fStrikeH"/>
178
				        <xsl:with-param name="fStrikeV" select="$fStrikeV"/>
179
				        <xsl:with-param name="fStrikeBLTR" select="$fStrikeBLTR"/>
180
				        <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR"/>
181
			      </xsl:call-template>
182
			      <xsl:apply-templates select="m:e[1]"/>
183
		    </menclose>
184
	  </xsl:template>
185

    
186
	  <xsl:template match="*">
187
		    <xsl:apply-templates select="*"/>
188
	  </xsl:template>
189

    
190
	  <xsl:template match="m:acc">
191
		    <mover>
192
			      <xsl:attribute name="accent">true</xsl:attribute>
193
			      <mrow>
194
				        <xsl:apply-templates select="m:e[1]"/>
195
			      </mrow>
196
			      <xsl:variable name="chAcc">
197
				        <xsl:choose>
198
					          <xsl:when test="not(m:accPr[last()]/m:chr)">
199
						            <xsl:value-of select="'̂'"/>
200
					          </xsl:when>
201
					          <xsl:otherwise>
202
						            <xsl:value-of select="substring(m:accPr/m:chr/@m:val,1,1)"/>
203
					          </xsl:otherwise>
204
				        </xsl:choose>
205
			      </xsl:variable>
206
			      <xsl:call-template name="ParseMt">
207
				        <xsl:with-param name="sToParse" select="$chAcc"/>
208
				        <xsl:with-param name="scr" select="m:e[1]/*/m:rPr[last()]/m:scr/@m:val"/>
209
				        <xsl:with-param name="sty" select="m:e[1]/*/m:rPr[last()]/m:sty/@m:val"/>
210
				        <xsl:with-param name="nor" select="m:e[1]/*/m:rPr[last()]/m:nor/@m:val"/>
211
			      </xsl:call-template>
212
		    </mover>
213
	  </xsl:template>
214

    
215
	  <xsl:template match="m:sPre">
216
		    <mmultiscripts>
217
			      <mrow>
218
				        <xsl:apply-templates select="m:e[1]"/>
219
			      </mrow>
220
			      <mprescripts/>
221
			      <mrow>
222
				        <xsl:apply-templates select="m:sub[1]"/>
223
			      </mrow>
224
			      <mrow>
225
				        <xsl:apply-templates select="m:sup[1]"/>
226
			      </mrow>
227
		    </mmultiscripts>
228
	  </xsl:template>
229

    
230
	  <xsl:template match="m:m">
231
		    <mtable>
232
			      <xsl:call-template name="CreateMathMLMatrixAttr">
233
				        <xsl:with-param name="mcJc" select="m:mPr[last()]/m:mcs/m:mc/m:mcPr[last()]/m:mcJc/@m:val"/>
234
			      </xsl:call-template>
235
			      <xsl:for-each select="m:mr">
236
				        <mtr>
237
					          <xsl:for-each select="m:e">
238
						            <mtd>
239
							              <xsl:apply-templates select="."/>
240
						            </mtd>
241
					          </xsl:for-each>
242
				        </mtr>
243
			      </xsl:for-each>
244
		    </mtable>
245
	  </xsl:template>
246

    
247
	  <xsl:template name="CreateMathMLMatrixAttr">
248
		    <xsl:param name="mcJc"/>
249
		    <xsl:variable name="sLowerCaseMcjc"
250
                    select="translate($mcJc, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',                                                                 'abcdefghijklmnopqrstuvwxyz')"/>
251
		    <xsl:choose>
252
			      <xsl:when test="$sLowerCaseMcjc='left'">
253
				        <xsl:attribute name="columnalign">left</xsl:attribute>
254
			      </xsl:when>
255
			      <xsl:when test="$sLowerCaseMcjc='right'">
256
				        <xsl:attribute name="columnalign">right</xsl:attribute>
257
			      </xsl:when>
258
		    </xsl:choose>
259
	  </xsl:template>
260

    
261
	  <xsl:template match="m:phant">
262
		    <xsl:variable name="sLowerCaseZeroWidVal"
263
                    select="translate(m:phantPr[last()]/m:zeroWid[last()]/@m:val,                                                           'ABCDEFGHIJKLMNOPQRSTUVWXYZ',                                                           'abcdefghijklmnopqrstuvwxyz')"/>
264
		    <xsl:variable name="sLowerCaseZeroAscVal"
265
                    select="translate(m:phantPr[last()]/m:zeroAsc[last()]/@m:val,                                                         'ABCDEFGHIJKLMNOPQRSTUVWXYZ',                                                         'abcdefghijklmnopqrstuvwxyz')"/>
266
		    <xsl:variable name="sLowerCaseZeroDescVal"
267
                    select="translate(m:phantPr[last()]/m:zeroDesc[last()]/@m:val,                                                         'ABCDEFGHIJKLMNOPQRSTUVWXYZ',                                                         'abcdefghijklmnopqrstuvwxyz')"/>
268
		    <xsl:variable name="sLowerCaseShowVal"
269
                    select="translate(m:phantPr[last()]/m:show[last()]/@m:val,                                                         'ABCDEFGHIJKLMNOPQRSTUVWXYZ',                                                         'abcdefghijklmnopqrstuvwxyz')"/>
270

    
271

    
272
		    <!-- The following properties default to 'yes' unless the last value equals 'no' or there isn't any node for 
273
         the property -->
274

    
275
		<xsl:variable name="fZeroWid">
276
			      <xsl:choose>
277
				        <xsl:when test="count(m:phantPr[last()]/m:zeroWid[last()]) = 0">0</xsl:when>
278
				        <xsl:when test="$sLowerCaseZeroWidVal = 'off'">0</xsl:when>
279
				        <xsl:otherwise>1</xsl:otherwise>
280
			      </xsl:choose>
281
		    </xsl:variable>
282
		    <xsl:variable name="fZeroAsc">
283
			      <xsl:choose>
284
				        <xsl:when test="count(m:phantPr[last()]/m:zeroAsc[last()]) = 0">0</xsl:when>
285
				        <xsl:when test="$sLowerCaseZeroAscVal = 'off'">0</xsl:when>
286
				        <xsl:otherwise>1</xsl:otherwise>
287
			      </xsl:choose>
288
		    </xsl:variable>
289
		    <xsl:variable name="fZeroDesc">
290
			      <xsl:choose>
291
				        <xsl:when test="count(m:phantPr[last()]/m:zeroDesc[last()]) = 0">0</xsl:when>
292
				        <xsl:when test="$sLowerCaseZeroDescVal = 'off'">0</xsl:when>
293
				        <xsl:otherwise>1</xsl:otherwise>
294
			      </xsl:choose>
295
		    </xsl:variable>
296

    
297
		    <!-- The show property defaults to 'on' unless there exists a show property and its value is 'off' -->
298

    
299
		<xsl:variable name="fShow">
300
			      <xsl:choose>
301
				        <xsl:when test="$sLowerCaseShowVal = 'off'">0</xsl:when>
302
				        <xsl:otherwise>1</xsl:otherwise>
303
			      </xsl:choose>
304
		    </xsl:variable>
305

    
306
		    <xsl:choose>
307
			<!-- Show the phantom contents, therefore, just use mpadded. -->
308
			<xsl:when test="$fShow = 1">
309
				        <xsl:element name="mpadded">
310
					          <xsl:call-template name="CreateMpaddedAttributes">
311
						            <xsl:with-param name="fZeroWid" select="$fZeroWid"/>
312
						            <xsl:with-param name="fZeroAsc" select="$fZeroAsc"/>
313
						            <xsl:with-param name="fZeroDesc" select="$fZeroDesc"/>
314
					          </xsl:call-template>
315
					          <mrow>
316
						            <xsl:apply-templates select="m:e"/>
317
					          </mrow>
318
				        </xsl:element>
319
			      </xsl:when>
320
			      <!-- Don't show phantom contents, but don't smash anything, therefore, just 
321
           use mphantom -->
322
			<xsl:when test="$fZeroWid=0 and $fZeroAsc=0 and $fZeroDesc=0">
323
				        <xsl:element name="mphantom">
324
					          <mrow>
325
						            <xsl:apply-templates select="m:e"/>
326
					          </mrow>
327
				        </xsl:element>
328
			      </xsl:when>
329
			      <!-- Combination -->
330
			<xsl:otherwise>
331
				        <xsl:element name="mphantom">
332
					          <xsl:element name="mpadded">
333
						            <xsl:call-template name="CreateMpaddedAttributes">
334
							              <xsl:with-param name="fZeroWid" select="$fZeroWid"/>
335
							              <xsl:with-param name="fZeroAsc" select="$fZeroAsc"/>
336
							              <xsl:with-param name="fZeroDesc" select="$fZeroDesc"/>
337
						            </xsl:call-template>
338
						            <mrow>
339
							              <xsl:apply-templates select="m:e"/>
340
						            </mrow>
341
					          </xsl:element>
342
				        </xsl:element>
343
			      </xsl:otherwise>
344
		    </xsl:choose>
345
	  </xsl:template>
346

    
347
	  <xsl:template name="CreateMpaddedAttributes">
348
		    <xsl:param name="fZeroWid"/>
349
		    <xsl:param name="fZeroAsc"/>
350
		    <xsl:param name="fZeroDesc"/>
351

    
352
		    <xsl:if test="$fZeroWid=1">
353
			      <xsl:attribute name="width">0</xsl:attribute>
354
		    </xsl:if>
355
		    <xsl:if test="$fZeroAsc=1">
356
			      <xsl:attribute name="height">0</xsl:attribute>
357
		    </xsl:if>
358
		    <xsl:if test="$fZeroDesc=1">
359
			      <xsl:attribute name="depth">0</xsl:attribute>
360
		    </xsl:if>
361
	  </xsl:template>
362

    
363

    
364

    
365
	  <xsl:template match="m:rad">
366
		    <xsl:variable name="sLowerCaseDegHide"
367
                    select="translate(m:radPr[last()]/m:degHide/@m:val,                                                              'ABCDEFGHIJKLMNOPQRSTUVWXYZ',                                                              'abcdefghijklmnopqrstuvwxyz')"/>
368
		    <xsl:choose>
369
			      <xsl:when test="$sLowerCaseDegHide='on'">
370
				        <msqrt>
371
					          <xsl:apply-templates select="m:e[1]"/>
372
				        </msqrt>
373
			      </xsl:when>
374
			      <xsl:otherwise>
375
				        <mroot>
376
					          <mrow>
377
						            <xsl:apply-templates select="m:e[1]"/>
378
					          </mrow>
379
					          <mrow>
380
						            <xsl:apply-templates select="m:deg[1]"/>
381
					          </mrow>
382
				        </mroot>
383
			      </xsl:otherwise>
384
		    </xsl:choose>
385
	  </xsl:template>
386

    
387
	  <!-- %%Template match m:nary 
388
		Process an n-ary. 
389
		
390
		Decides, based on which arguments are supplied, between
391
		using an mo, msup, msub, or msubsup for the n-ary operator		
392
	-->
393
	<xsl:template match="m:nary">
394
		    <xsl:variable name="sLowerCaseSubHide">
395
			      <xsl:choose>
396
				        <xsl:when test="count(m:naryPr[last()]/m:subHide) = 0">
397
					          <xsl:text>off</xsl:text>
398
				        </xsl:when>
399
				        <xsl:otherwise>
400
					          <xsl:value-of select="translate(m:naryPr[last()]/m:subHide/@m:val,                                     'ABCDEFGHIJKLMNOPQRSTUVWXYZ',                                     'abcdefghijklmnopqrstuvwxyz')"/>
401
				        </xsl:otherwise>
402
			      </xsl:choose>
403
		    </xsl:variable>
404
		    <xsl:variable name="sLowerCaseSupHide">
405
			      <xsl:choose>
406
				        <xsl:when test="count(m:naryPr[last()]/m:supHide) = 0">
407
					          <xsl:text>off</xsl:text>
408
				        </xsl:when>
409
				        <xsl:otherwise>
410
					          <xsl:value-of select="translate(m:naryPr[last()]/m:supHide/@m:val,                                     'ABCDEFGHIJKLMNOPQRSTUVWXYZ',                                     'abcdefghijklmnopqrstuvwxyz')"/>
411
				        </xsl:otherwise>
412
			      </xsl:choose>
413
		    </xsl:variable>
414
		    <xsl:variable name="sLowerCaseLimLoc">
415
			      <xsl:value-of select="translate(m:naryPr[last()]/m:limLoc/@m:val,                                     'ABCDEFGHIJKLMNOPQRSTUVWXYZ',                                     'abcdefghijklmnopqrstuvwxyz')"/>
416
		    </xsl:variable>
417
		    <xsl:variable name="fLimLocSubSup">
418
			      <xsl:choose>
419
				        <xsl:when test="count(m:naryPr[last()]/m:limLoc)=0 or $sLowerCaseLimLoc='subsup'">1</xsl:when>
420
				        <xsl:otherwise>0</xsl:otherwise>
421
			      </xsl:choose>
422
		    </xsl:variable>
423
		    <xsl:choose>
424
			      <xsl:when test="not($sLowerCaseSupHide='off') and                     not($sLowerCaseSubHide='off')">
425
				        <mo>
426
					          <xsl:choose>
427
						            <xsl:when test="not(m:naryPr[last()]/m:chr/@m:val) or                                m:naryPr[last()]/m:chr/@m:val=''">
428
							              <xsl:text>&#x222b;</xsl:text>
429
						            </xsl:when>
430
						            <xsl:otherwise>
431
							              <xsl:value-of select="m:naryPr[last()]/m:chr/@m:val"/>
432
						            </xsl:otherwise>
433
					          </xsl:choose>
434
				        </mo>
435
			      </xsl:when>
436
			      <xsl:when test="not($sLowerCaseSubHide='off')">
437
				        <xsl:choose>
438
					          <xsl:when test="$fLimLocSubSup=1">
439
						            <msup>
440
							              <mo>
441
								                <xsl:choose>
442
									                  <xsl:when test="not(m:naryPr[last()]/m:chr/@m:val) or                                            m:naryPr[last()]/m:chr/@m:val=''">
443
										                    <xsl:text>&#x222b;</xsl:text>
444
									                  </xsl:when>
445
									                  <xsl:otherwise>
446
										                    <xsl:value-of select="m:naryPr[last()]/m:chr/@m:val"/>
447
									                  </xsl:otherwise>
448
								                </xsl:choose>
449
							              </mo>
450
							              <mrow>
451
								                <xsl:apply-templates select="m:sup[1]"/>
452
							              </mrow>
453
						            </msup>
454
					          </xsl:when>
455
					          <xsl:otherwise>
456
						            <mover>
457
							              <mo>
458
								                <xsl:choose>
459
									                  <xsl:when test="not(m:naryPr[last()]/m:chr/@m:val) or                                            m:naryPr[last()]/m:chr/@m:val=''">
460
										                    <xsl:text>&#x222b;</xsl:text>
461
									                  </xsl:when>
462
									                  <xsl:otherwise>
463
										                    <xsl:value-of select="m:naryPr[last()]/m:chr/@m:val"/>
464
									                  </xsl:otherwise>
465
								                </xsl:choose>
466
							              </mo>
467
							              <mrow>
468
								                <xsl:apply-templates select="m:sup[1]"/>
469
							              </mrow>
470
						            </mover>
471
					          </xsl:otherwise>
472
				        </xsl:choose>
473
			      </xsl:when>
474
			      <xsl:when test="not($sLowerCaseSupHide='off')">
475
				        <xsl:choose>
476
					          <xsl:when test="$fLimLocSubSup=1">
477
						            <msub>
478
							              <mo>
479
								                <xsl:choose>
480
									                  <xsl:when test="not(m:naryPr[last()]/m:chr/@m:val) or                                            m:naryPr[last()]/m:chr/@m:val=''">
481
										                    <xsl:text>&#x222b;</xsl:text>
482
									                  </xsl:when>
483
									                  <xsl:otherwise>
484
										                    <xsl:value-of select="m:naryPr[last()]/m:chr/@m:val"/>
485
									                  </xsl:otherwise>
486
								                </xsl:choose>
487
							              </mo>
488
							              <mrow>
489
								                <xsl:apply-templates select="m:sub[1]"/>
490
							              </mrow>
491
						            </msub>
492
					          </xsl:when>
493
					          <xsl:otherwise>
494
						            <munder>
495
							              <mo>
496
								                <xsl:choose>
497
									                  <xsl:when test="not(m:naryPr[last()]/m:chr/@m:val) or                            m:naryPr[last()]/m:chr/@m:val=''">
498
										                    <xsl:text>&#x222b;</xsl:text>
499
									                  </xsl:when>
500
									                  <xsl:otherwise>
501
										                    <xsl:value-of select="m:naryPr[last()]/m:chr/@m:val"/>
502
									                  </xsl:otherwise>
503
								                </xsl:choose>
504
							              </mo>
505
							              <mrow>
506
								                <xsl:apply-templates select="m:sub[1]"/>
507
							              </mrow>
508
						            </munder>
509
					          </xsl:otherwise>
510
				        </xsl:choose>
511
			      </xsl:when>
512
			      <xsl:otherwise>
513
				        <xsl:choose>
514
					          <xsl:when test="$fLimLocSubSup=1">
515
						            <msubsup>
516
							              <mo>
517
								                <xsl:choose>
518
									                  <xsl:when test="not(m:naryPr[last()]/m:chr/@m:val) or                                            m:naryPr[last()]/m:chr/@m:val=''">
519
										                    <xsl:text>&#x222b;</xsl:text>
520
									                  </xsl:when>
521
									                  <xsl:otherwise>
522
										                    <xsl:value-of select="m:naryPr[last()]/m:chr/@m:val"/>
523
									                  </xsl:otherwise>
524
								                </xsl:choose>
525
							              </mo>
526
							              <mrow>
527
								                <xsl:apply-templates select="m:sub[1]"/>
528
							              </mrow>
529
							              <mrow>
530
								                <xsl:apply-templates select="m:sup[1]"/>
531
							              </mrow>
532
						            </msubsup>
533
					          </xsl:when>
534
					          <xsl:otherwise>
535
						            <munderover>
536
							              <mo>
537
								                <xsl:choose>
538
									                  <xsl:when test="not(m:naryPr[last()]/m:chr/@m:val) or                                            m:naryPr[last()]/m:chr/@m:val=''">
539
										                    <xsl:text>&#x222b;</xsl:text>
540
									                  </xsl:when>
541
									                  <xsl:otherwise>
542
										                    <xsl:value-of select="m:naryPr[last()]/m:chr/@m:val"/>
543
									                  </xsl:otherwise>
544
								                </xsl:choose>
545
							              </mo>
546
							              <mrow>
547
								                <xsl:apply-templates select="m:sub[1]"/>
548
							              </mrow>
549
							              <mrow>
550
								                <xsl:apply-templates select="m:sup[1]"/>
551
							              </mrow>
552
						            </munderover>
553
					          </xsl:otherwise>
554
				        </xsl:choose>
555
			      </xsl:otherwise>
556
		    </xsl:choose>
557
		    <mrow>
558
			      <xsl:apply-templates select="m:e[1]"/>
559
		    </mrow>
560
	  </xsl:template>
561

    
562
	  <xsl:template match="m:limLow">
563
		    <munder>
564
			      <mrow>
565
				        <xsl:apply-templates select="m:e[1]"/>
566
			      </mrow>
567
			      <mrow>
568
				        <xsl:apply-templates select="m:lim[1]"/>
569
			      </mrow>
570
		    </munder>
571
	  </xsl:template>
572

    
573
	  <xsl:template match="m:limUpp">
574
		    <mover>
575
			      <mrow>
576
				        <xsl:apply-templates select="m:e[1]"/>
577
			      </mrow>
578
			      <mrow>
579
				        <xsl:apply-templates select="m:lim[1]"/>
580
			      </mrow>
581
		    </mover>
582
	  </xsl:template>
583

    
584
	  <xsl:template match="m:sSub">
585
		    <msub>
586
			      <mrow>
587
				        <xsl:apply-templates select="m:e[1]"/>
588
			      </mrow>
589
			      <mrow>
590
				        <xsl:apply-templates select="m:sub[1]"/>
591
			      </mrow>
592
		    </msub>
593
	  </xsl:template>
594

    
595
	  <xsl:template match="m:sSup">
596
		    <msup>
597
			      <mrow>
598
				        <xsl:apply-templates select="m:e[1]"/>
599
			      </mrow>
600
			      <mrow>
601
				        <xsl:apply-templates select="m:sup[1]"/>
602
			      </mrow>
603
		    </msup>
604
	  </xsl:template>
605

    
606
	  <xsl:template match="m:sSubSup">
607
		    <msubsup>
608
			      <mrow>
609
				        <xsl:apply-templates select="m:e[1]"/>
610
			      </mrow>
611
			      <mrow>
612
				        <xsl:apply-templates select="m:sub[1]"/>
613
			      </mrow>
614
			      <mrow>
615
				        <xsl:apply-templates select="m:sup[1]"/>
616
			      </mrow>
617
		    </msubsup>
618
	  </xsl:template>
619

    
620
	  <xsl:template match="m:groupChr">
621
		    <xsl:variable name="ndLastGroupChrPr" select="m:groupChrPr[last()]"/>
622
		    <xsl:variable name="sLowerCasePos"
623
                    select="translate($ndLastGroupChrPr/m:pos/@m:val,                                                         'ABCDEFGHIJKLMNOPQRSTUVWXYZ',                                                         'abcdefghijklmnopqrstuvwxyz')"/>
624

    
625
		    <xsl:variable name="sLowerCaseVertJc"
626
                    select="translate($ndLastGroupChrPr/m:vertJc/@m:val,                                                         'ABCDEFGHIJKLMNOPQRSTUVWXYZ',                                                         'abcdefghijklmnopqrstuvwxyz')"/>
627
		    <xsl:variable name="ndLastChr" select="$ndLastGroupChrPr/m:chr"/>
628

    
629
		    <xsl:variable name="chr">
630
			      <xsl:choose>
631
				        <xsl:when test="$ndLastChr and (not($ndLastChr/@m:val) or string-length($ndLastChr/@m:val) = 0)"/>
632
				        <xsl:when test="string-length($ndLastChr/@m:val) &gt;= 1">
633
					          <xsl:value-of select="substring($ndLastChr/@m:val,1,1)"/>
634
				        </xsl:when>
635
				        <xsl:otherwise>
636
					          <xsl:text>&amp;#x023DF;</xsl:text>
637
				        </xsl:otherwise>
638
			      </xsl:choose>
639
		    </xsl:variable>
640
		    <xsl:choose>
641
			      <xsl:when test="$sLowerCasePos = 'top'">
642
				        <xsl:choose>
643
					          <xsl:when test="$sLowerCaseVertJc = 'bot'">
644
						            <mover accent="false">
645
							              <mrow>
646
								                <xsl:apply-templates select="m:e[1]"/>
647
							              </mrow>
648
							              <mo>
649
								                <xsl:value-of disable-output-escaping="yes" select="$chr"/>
650
							              </mo>
651
						            </mover>
652
					          </xsl:when>
653
					          <xsl:otherwise>
654
						            <munder accentunder="false">
655
							              <mo>
656
								                <xsl:value-of disable-output-escaping="yes" select="$chr"/>
657
							              </mo>
658
							              <mrow>
659
								                <xsl:apply-templates select="m:e[1]"/>
660
							              </mrow>
661
						            </munder>
662
					          </xsl:otherwise>
663
				        </xsl:choose>
664
			      </xsl:when>
665
			      <xsl:otherwise>
666
				        <xsl:choose>
667
					          <xsl:when test="$sLowerCaseVertJc = 'bot'">
668
						            <mover accent="false">
669
							              <mo>
670
								                <xsl:value-of disable-output-escaping="yes" select="$chr"/>
671
							              </mo>
672
							              <mrow>
673
								                <xsl:apply-templates select="m:e[1]"/>
674
							              </mrow>
675
						            </mover>
676
					          </xsl:when>
677
					          <xsl:otherwise>
678
						            <munder accentunder="false">
679
							              <mrow>
680
								                <xsl:apply-templates select="m:e[1]"/>
681
							              </mrow>
682
							              <mo>
683
								                <xsl:value-of disable-output-escaping="yes" select="$chr"/>
684
							              </mo>
685
						            </munder>
686
					          </xsl:otherwise>
687
				        </xsl:choose>
688
			      </xsl:otherwise>
689
		    </xsl:choose>
690
	  </xsl:template>
691

    
692
	  <xsl:template name="fName">
693
		    <xsl:for-each select="m:fName/*">
694
			      <xsl:apply-templates select="."/>
695
		    </xsl:for-each>
696
	  </xsl:template>
697

    
698
	  <xsl:template match="m:func">
699
		    <mrow>
700
			      <mrow>
701
				        <xsl:call-template name="fName"/>
702
			      </mrow>
703
			      <mo>⁡</mo>
704
			      <mrow>
705
				        <xsl:apply-templates select="m:e"/>
706
			      </mrow>
707
		    </mrow>
708
	  </xsl:template>
709

    
710
	  <!-- %%Template: match m:f 
711
		
712
		m:f maps directly to mfrac. 
713
	-->
714
	<xsl:template match="m:f">
715
		    <xsl:variable name="sLowerCaseType"
716
                    select="translate(m:fPr[last()]/m:type/@m:val, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')"/>
717
		    <xsl:choose>
718
			      <xsl:when test="$sLowerCaseType='lin'">
719
				        <mrow>
720
					          <mrow>
721
						            <xsl:apply-templates select="m:num[1]"/>
722
					          </mrow>
723
					          <mo>/</mo>
724
					          <mrow>
725
						            <xsl:apply-templates select="m:den[1]"/>
726
					          </mrow>
727
				        </mrow>
728
			      </xsl:when>
729
			      <xsl:otherwise>
730
				        <mfrac>
731
					          <xsl:call-template name="CreateMathMLFracProp">
732
						            <xsl:with-param name="type" select="$sLowerCaseType"/>
733
					          </xsl:call-template>
734
					          <mrow>
735
						            <xsl:apply-templates select="m:num[1]"/>
736
					          </mrow>
737
					          <mrow>
738
						            <xsl:apply-templates select="m:den[1]"/>
739
					          </mrow>
740
				        </mfrac>
741
			      </xsl:otherwise>
742
		    </xsl:choose>
743

    
744
	  </xsl:template>
745

    
746

    
747
	  <!-- %%Template: CreateMathMLFracProp 
748
		
749
			Make fraction properties based on supplied parameters.
750
			OMML differentiates between a linear fraction and a skewed
751
			one. For MathML, we write both as bevelled.
752
	-->
753
	<xsl:template name="CreateMathMLFracProp">
754
		    <xsl:param name="type"/>
755
		    <xsl:variable name="sLowerCaseType"
756
                    select="translate($type, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')"/>
757

    
758
		    <xsl:if test="$sLowerCaseType='skw' or $sLowerCaseType='lin'">
759
			      <xsl:attribute name="bevelled">true</xsl:attribute>
760
		    </xsl:if>
761
		    <xsl:if test="$sLowerCaseType='nobar'">
762
			      <xsl:attribute name="linethickness">0pt</xsl:attribute>
763
		    </xsl:if>
764
		    <xsl:choose>
765
			      <xsl:when test="sLowerCaseNumJc='right'">
766
				        <xsl:attribute name="numalign">right</xsl:attribute>
767
			      </xsl:when>
768
			      <xsl:when test="sLowerCaseNumJc='left'">
769
				        <xsl:attribute name="numalign">left</xsl:attribute>
770
			      </xsl:when>
771
		    </xsl:choose>
772
		    <xsl:choose>
773
			      <xsl:when test="sLowerCaseDenJc='right'">
774
				        <xsl:attribute name="numalign">right</xsl:attribute>
775
			      </xsl:when>
776
			      <xsl:when test="sLowerCaseDenJc='left'">
777
				        <xsl:attribute name="numalign">left</xsl:attribute>
778
			      </xsl:when>
779
		    </xsl:choose>
780
	  </xsl:template>
781

    
782
	  <!-- %%Template: match m:e | m:den | m:num | m:lim | m:sup | m:sub 
783
		
784
		These element delinate parts of an expression (like the numerator).  -->
785
	<xsl:template match="m:e | m:den | m:num | m:lim | m:sup | m:sub">
786
		    <xsl:choose>
787

    
788
			<!-- If there is no scriptLevel specified, just call through -->
789
			<xsl:when test="not(m:argPr[last()]/m:scrLvl/@m:val)">
790
				        <xsl:apply-templates select="*"/>
791
			      </xsl:when>
792

    
793
			      <!-- Otherwise, create an mstyle and set the script level -->
794
			<xsl:otherwise>
795
				        <mstyle>
796
					          <xsl:attribute name="scriptlevel">
797
						            <xsl:value-of select="m:argPr[last()]/m:scrLvl/@m:val"/>
798
					          </xsl:attribute>
799
					          <xsl:apply-templates select="*"/>
800
				        </mstyle>
801
			      </xsl:otherwise>
802
		    </xsl:choose>
803
	  </xsl:template>
804

    
805
	  <xsl:template match="m:bar">
806
		    <xsl:variable name="sLowerCasePos"
807
                    select="translate(m:barPr/m:pos/@m:val, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',                                                                           'abcdefghijklmnopqrstuvwxyz')"/>
808

    
809
		    <xsl:variable name="fTop">
810

    
811
			      <xsl:choose>
812
				        <xsl:when test="$sLowerCasePos='top'">1</xsl:when>
813
				        <xsl:otherwise>0</xsl:otherwise>
814
			      </xsl:choose>
815
		    </xsl:variable>
816
		    <xsl:choose>
817
			      <xsl:when test="$fTop=1">
818
				        <mover>
819
					          <mrow>
820
						            <xsl:apply-templates select="m:e[1]"/>
821
					          </mrow>
822
					          <mo>
823
						            <xsl:text>&#x000AF;</xsl:text>
824
					          </mo>
825
				        </mover>
826
			      </xsl:when>
827
			      <xsl:otherwise>
828
				        <munder>
829
					          <mrow>
830
						            <xsl:apply-templates select="m:e[1]"/>
831
					          </mrow>
832
					          <mo>
833
						            <xsl:text>&#x00332;</xsl:text>
834
					          </mo>
835
				        </munder>
836
			      </xsl:otherwise>
837
		    </xsl:choose>
838
	  </xsl:template>
839

    
840
	  <!-- %%Template match m:d
841

    
842
		Process a delimiter. 
843
	-->
844
	<xsl:template match="m:d">
845
		    <mfenced>
846
			<!-- open: default is '(' for both OMML and MathML -->
847
			<xsl:if test="m:dPr[1]/m:begChr/@m:val and not(m:dPr[1]/m:begChr/@m:val ='(')">
848
				        <xsl:attribute name="open">
849
					          <xsl:value-of select="m:dPr[1]/m:begChr/@m:val"/>
850
				        </xsl:attribute>
851
			      </xsl:if>
852

    
853
			      <!-- close: default is ')' for both OMML and MathML -->
854
			<xsl:if test="m:dPr[1]/m:endChr/@m:val and not(m:dPr[1]/m:endChr/@m:val =')')">
855
				        <xsl:attribute name="close">
856
					          <xsl:value-of select="m:dPr[1]/m:endChr/@m:val"/>
857
				        </xsl:attribute>
858
			      </xsl:if>
859

    
860
			      <!-- separator: the default is ',' for MathML, and '|' for OMML -->
861
			<xsl:choose>
862
				<!-- Matches MathML default. Write nothing -->
863
				<xsl:when test="m:dPr[1]/m:sepChr/@m:val = ','"/>
864

    
865
				        <!-- OMML default: | -->
866
				<xsl:when test="not(m:dPr[1]/m:sepChr/@m:val)">
867
					          <xsl:attribute name="separators">
868
						            <xsl:value-of select="'|'"/>
869
					          </xsl:attribute>
870
				        </xsl:when>
871

    
872
				        <xsl:otherwise>
873
					          <xsl:attribute name="separators">
874
						            <xsl:value-of select="m:dPr[1]/m:sepChr/@m:val"/>
875
					          </xsl:attribute>
876
				        </xsl:otherwise>
877
			      </xsl:choose>
878

    
879
			      <!-- now write all the children. Put each one into an mrow
880
			just in case it produces multiple runs, etc -->
881
			<xsl:for-each select="m:e">
882
				        <mrow>
883
					          <xsl:apply-templates select="."/>
884
				        </mrow>
885
			      </xsl:for-each>
886
		    </mfenced>
887
	  </xsl:template>
888

    
889
	  <xsl:template match="m:r">
890
		    <xsl:variable name="sLowerCaseNor"
891
                    select="translate(child::m:rPr[last()]/m:nor/@m:val, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',                                                                           'abcdefghijklmnopqrstuvwxyz')"/>
892
		    <xsl:variable name="sLowerCaseLit"
893
                    select="translate(child::m:rPr[child::m:lit][last()]/@m:val, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',                                                                           'abcdefghijklmnopqrstuvwxyz')"/>
894

    
895
		    <xsl:variable name="fNor">
896
			      <xsl:choose>
897
				        <xsl:when test="$sLowerCaseNor='off' or count(child::m:rPr[last()]/m:nor) = 0">0</xsl:when>
898
				        <xsl:otherwise>1</xsl:otherwise>
899
			      </xsl:choose>
900
		    </xsl:variable>
901
		    <xsl:variable name="fLit">
902
			      <xsl:choose>
903
				        <xsl:when test="not(child::m:rPr[child::m:lit][last()]) or $sLowerCaseLit='off'">0</xsl:when>
904
				        <xsl:otherwise>1</xsl:otherwise>
905
			      </xsl:choose>
906
		    </xsl:variable>
907

    
908
		    <xsl:choose>
909
			      <xsl:when test="$fNor=1">
910
				        <xsl:choose>
911
					          <xsl:when test="$fLit=1">
912
						            <maction actiontype="lit">
913
							              <mtext>
914
									<xsl:call-template name="checkDirectFormatting"/>
915
								                <xsl:value-of select=".//m:t"/>
916
							              </mtext>
917
						            </maction>
918
					          </xsl:when>
919
					          <xsl:otherwise>
920
						            <mtext>
921
									<xsl:call-template name="checkDirectFormatting"/>
922
							              <xsl:value-of select=".//m:t"/>
923
						            </mtext>
924
					          </xsl:otherwise>
925
				        </xsl:choose>
926
			      </xsl:when>
927
			      <xsl:otherwise>
928
				        <xsl:choose>
929
					          <xsl:when test="$fLit=1">
930
						            <maction actiontype="lit">
931
							              <xsl:for-each select=".//m:t">
932
								                <xsl:call-template name="ParseMt">
933
									                  <xsl:with-param name="sToParse" select="text()"/>
934
									                  <xsl:with-param name="scr" select="../m:rPr[last()]/m:scr/@m:val"/>
935
									                  <xsl:with-param name="sty" select="../m:rPr[last()]/m:sty/@m:val"/>
936
									                  <xsl:with-param name="nor" select="../m:rPr[last()]/m:nor/@m:val"/>
937
								                </xsl:call-template>
938
							              </xsl:for-each>
939
						            </maction>
940
					          </xsl:when>
941
					          <xsl:otherwise>
942
						            <xsl:for-each select=".//m:t">
943
							              <xsl:call-template name="ParseMt">
944
								                <xsl:with-param name="sToParse" select="text()"/>
945
								                <xsl:with-param name="scr" select="../m:rPr[last()]/m:scr/@m:val"/>
946
								                <xsl:with-param name="sty" select="../m:rPr[last()]/m:sty/@m:val"/>
947
								                <xsl:with-param name="nor" select="../m:rPr[last()]/m:nor/@m:val"/>
948
							              </xsl:call-template>
949
						            </xsl:for-each>
950
					          </xsl:otherwise>
951
				        </xsl:choose>
952
			      </xsl:otherwise>
953
		    </xsl:choose>
954
	  </xsl:template>
955

    
956

    
957
	  <xsl:template name="CreateTokenAttributes">
958
		    <xsl:param name="scr"/>
959
		    <xsl:param name="sty"/>
960
		    <xsl:param name="nor"/>
961
		    <xsl:param name="nCharToPrint"/>
962
		    <xsl:param name="sTokenType"/>
963
		    <xsl:variable name="sLowerCaseNor"
964
                    select="translate($nor, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',                                                               'abcdefghijklmnopqrstuvwxyz')"/>
965
		    <xsl:choose>
966
			      <xsl:when test="$sLowerCaseNor = 'on'">
967
				        <xsl:attribute name="mathvariant">normal</xsl:attribute>
968
			      </xsl:when>
969
			      <xsl:otherwise>
970
				        <xsl:variable name="mathvariant">
971
					          <xsl:choose>
972
						<!-- numbers don't care -->
973
						<xsl:when test="$sTokenType='mn'"/>
974

    
975
						            <xsl:when test="$scr='monospace'">monospace</xsl:when>
976
						            <xsl:when test="$scr='sans-serif' and $sty='i'">sans-serif-italic</xsl:when>
977
						            <xsl:when test="$scr='sans-serif' and $sty='b'">bold-sans-serif</xsl:when>
978
						            <xsl:when test="$scr='sans-serif' and $sty='bi'">sans-serif-bold-italic</xsl:when>
979
						            <xsl:when test="$scr='sans-serif'">sans-serif</xsl:when>
980
						            <xsl:when test="$scr='fraktur' and $sty='b'">bold-fraktur</xsl:when>
981
						            <xsl:when test="$scr='fraktur'">fraktur</xsl:when>
982
						            <xsl:when test="$scr='double-struck'">double-struck</xsl:when>
983
						            <xsl:when test="$scr='script' and $sty='b'">bold-script</xsl:when>
984
						            <xsl:when test="$scr='script'">script</xsl:when>
985
						            <xsl:when test="($scr='roman' or not($scr) or $scr='') and $sty='b'">bold</xsl:when>
986
						            <xsl:when test="($scr='roman' or not($scr) or $scr='') and $sty='i'">italic</xsl:when>
987
						            <xsl:when test="($scr='roman' or not($scr) or $scr='') and $sty='p'">normal</xsl:when>
988
						            <xsl:when test="($scr='roman' or not($scr) or $scr='') and $sty='bi'">bold-italic</xsl:when>
989
						            <xsl:otherwise/>
990
					          </xsl:choose>
991
				        </xsl:variable>
992
				        <xsl:variable name="fontweight">
993
					          <xsl:choose>
994
						            <xsl:when test="$sty='b' or $sty='bi'">bold</xsl:when>
995
						            <xsl:otherwise>normal</xsl:otherwise>
996
					          </xsl:choose>
997
				        </xsl:variable>
998
				        <xsl:variable name="fontstyle">
999
					          <xsl:choose>
1000
						            <xsl:when test="$sty='p' or $sty='b'">normal</xsl:when>
1001
						            <xsl:otherwise>italic</xsl:otherwise>
1002
					          </xsl:choose>
1003
				        </xsl:variable>
1004

    
1005
				        <!-- Writing of attributes begins here -->
1006
				<xsl:choose>
1007
					<!-- Don't write mathvariant for operators unless they want to be normal -->
1008
					<xsl:when test="$sTokenType='mo' and $mathvariant!='normal'"/>
1009

    
1010
					          <!-- A single character within an mi is already italics, don't write -->
1011
					<xsl:when test="$sTokenType='mi' and $nCharToPrint=1 and ($mathvariant='' or $mathvariant='italic')"/>
1012

    
1013
					          <xsl:when test="$sTokenType='mi' and $nCharToPrint &gt; 1 and ($mathvariant='' or $mathvariant='italic')">
1014
						            <xsl:attribute name="mathvariant">
1015
							              <xsl:value-of select="'italic'"/>
1016
						            </xsl:attribute>
1017
					          </xsl:when>
1018
					          <xsl:when test="$mathvariant!='italic' and $mathvariant!=''">
1019
						            <xsl:attribute name="mathvariant">
1020
							              <xsl:value-of select="$mathvariant"/>
1021
						            </xsl:attribute>
1022
					          </xsl:when>
1023
					          <xsl:otherwise>
1024
						            <xsl:if test="not($sTokenType='mi' and $nCharToPrint=1) and $fontstyle='italic'">
1025
							              <xsl:attribute name="fontstyle">italic</xsl:attribute>
1026
						            </xsl:if>
1027
						            <xsl:if test="$fontweight='bold'">
1028
							              <xsl:attribute name="fontweight">bold</xsl:attribute>
1029
						            </xsl:if>
1030
					          </xsl:otherwise>
1031
				        </xsl:choose>
1032
			      </xsl:otherwise>
1033
		    </xsl:choose>
1034
	  </xsl:template>
1035

    
1036
	  <xsl:template match="m:eqArr">
1037
		    <mtable>
1038
			      <xsl:for-each select="m:e">
1039
				        <mtr>
1040
					          <mtd>
1041
						            <xsl:choose>
1042
							              <xsl:when test="m:argPr[last()]/m:scrLvl/@m:val!='0' or                   not(m:argPr[last()]/m:scrLvl/@m:val)  or                   m:argPr[last()]/m:scrLvl/@m:val=''">
1043
								                <mrow>
1044
									                  <maligngroup/>
1045
									                  <xsl:call-template name="CreateEqArrRow">
1046
										                    <xsl:with-param name="align" select="1"/>
1047
										                    <xsl:with-param name="ndCur" select="*[1]"/>
1048
									                  </xsl:call-template>
1049
								                </mrow>
1050
							              </xsl:when>
1051
							              <xsl:otherwise>
1052
								                <mstyle>
1053
									                  <xsl:attribute name="scriptlevel">
1054
										                    <xsl:value-of select="m:argPr[last()]/m:scrLvl/@m:val"/>
1055
									                  </xsl:attribute>
1056
									                  <maligngroup/>
1057
									                  <xsl:call-template name="CreateEqArrRow">
1058
										                    <xsl:with-param name="align" select="1"/>
1059
										                    <xsl:with-param name="ndCur" select="*[1]"/>
1060
									                  </xsl:call-template>
1061
								                </mstyle>
1062
							              </xsl:otherwise>
1063
						            </xsl:choose>
1064
					          </mtd>
1065
				        </mtr>
1066
			      </xsl:for-each>
1067
		    </mtable>
1068
	  </xsl:template>
1069

    
1070
	  <xsl:template name="CreateEqArrRow">
1071
		    <xsl:param name="align"/>
1072
		    <xsl:param name="ndCur"/>
1073
		    <xsl:variable name="sAllMt">
1074
			      <xsl:for-each select="$ndCur/m:t">
1075
				        <xsl:value-of select="."/>
1076
			      </xsl:for-each>
1077
		    </xsl:variable>
1078
		    <xsl:choose>
1079
			      <xsl:when test="$ndCur/self::m:r">
1080
				        <xsl:call-template name="ParseEqArrMr">
1081
					          <xsl:with-param name="sToParse" select="$sAllMt"/>
1082
					          <xsl:with-param name="scr" select="../m:rPr[last()]/m:scr/@m:val"/>
1083
					          <xsl:with-param name="sty" select="../m:rPr[last()]/m:sty/@m:val"/>
1084
					          <xsl:with-param name="nor" select="../m:rPr[last()]/m:nor/@m:val"/>
1085
					          <xsl:with-param name="align" select="$align"/>
1086
				        </xsl:call-template>
1087
			      </xsl:when>
1088
			      <xsl:otherwise>
1089
				        <xsl:apply-templates select="$ndCur"/>
1090
			      </xsl:otherwise>
1091
		    </xsl:choose>
1092
		    <xsl:if test="count($ndCur/following-sibling::*) &gt; 0">
1093
			      <xsl:variable name="cAmp">
1094
				        <xsl:call-template name="CountAmp">
1095
					          <xsl:with-param name="sAllMt" select="$sAllMt"/>
1096
					          <xsl:with-param name="cAmp" select="0"/>
1097
				        </xsl:call-template>
1098
			      </xsl:variable>
1099
			      <xsl:call-template name="CreateEqArrRow">
1100
				        <xsl:with-param name="align" select="($align+($cAmp mod 2)) mod 2"/>
1101
				        <xsl:with-param name="ndCur" select="$ndCur/following-sibling::*[1]"/>
1102
			      </xsl:call-template>
1103
		    </xsl:if>
1104
	  </xsl:template>
1105

    
1106
	  <xsl:template name="CountAmp">
1107
		    <xsl:param name="sAllMt"/>
1108
		    <xsl:param name="cAmp"/>
1109
		    <xsl:choose>
1110
			      <xsl:when test="string-length(substring-after($sAllMt, '&amp;')) &gt; 0 or                     substring($sAllMt, string-length($sAllMt))='&amp;'">
1111
				        <xsl:call-template name="CountAmp">
1112
					          <xsl:with-param name="sAllMt" select="substring-after($sAllMt, '&amp;')"/>
1113
					          <xsl:with-param name="cAmp" select="$cAmp+1"/>
1114
				        </xsl:call-template>
1115
			      </xsl:when>
1116
			      <xsl:otherwise>
1117
				        <xsl:value-of select="$cAmp"/>
1118
			      </xsl:otherwise>
1119
		    </xsl:choose>
1120
	  </xsl:template>
1121

    
1122
	  <!-- %%Template: ParseEqArrMr
1123
			
1124
			Similar to ParseMt, but this one has to do more for an equation array. 
1125
      In equation arrays &amp; is a special character which denotes alignment.
1126
      
1127
      The &amp; in an equation works by alternating between meaning insert alignment spacing
1128
      and insert alignment mark.  For each equation in the equation array
1129
      there is an implied align space at the beginning of the equation.  Within each equation,
1130
      the first &amp; means alignmark, the second, align space, the third, alignmark, etc.
1131
      
1132
      For this reason when parsing m:r's in equation arrays it is important to keep track of what
1133
      the next ampersand will mean.
1134
      
1135
      $align=0 => Omml's align space, which is similar to MathML's maligngroup.
1136
      $align=1 => Omml's alignment mark, which is similar to MathML's malignmark.
1137
	-->
1138
	<xsl:template name="ParseEqArrMr">
1139
		    <xsl:param name="sToParse"/>
1140
		    <xsl:param name="sty"/>
1141
		    <xsl:param name="scr"/>
1142
		    <xsl:param name="nor"/>
1143
		    <xsl:param name="align"/>
1144

    
1145
		    <xsl:if test="string-length($sToParse) &gt; 0">
1146
			      <xsl:choose>
1147
				        <xsl:when test="substring($sToParse,1,1) = '&amp;'">
1148
					          <xsl:choose>
1149
						            <xsl:when test="$align=0">
1150
							              <maligngroup/>
1151
						            </xsl:when>
1152
						            <xsl:when test="$align=1">
1153
							              <malignmark/>
1154
						            </xsl:when>
1155
					          </xsl:choose>
1156
					          <xsl:call-template name="ParseEqArrMr">
1157
						            <xsl:with-param name="sToParse" select="substring($sToParse,2)"/>
1158
						            <xsl:with-param name="scr" select="$scr"/>
1159
						            <xsl:with-param name="sty" select="$sty"/>
1160
						            <xsl:with-param name="nor" select="$nor"/>
1161
						            <xsl:with-param name="align">
1162
							              <xsl:choose>
1163
								                <xsl:when test="$align=1">0</xsl:when>
1164
								                <xsl:otherwise>1</xsl:otherwise>
1165
							              </xsl:choose>
1166
						            </xsl:with-param>
1167
					          </xsl:call-template>
1168
				        </xsl:when>
1169
				        <xsl:otherwise>
1170
					          <xsl:variable name="sRepNumWith0">
1171
						            <xsl:call-template name="SReplaceNumWithZero">
1172
							              <xsl:with-param name="sToParse" select="$sToParse"/>
1173
						            </xsl:call-template>
1174
					          </xsl:variable>
1175
					          <xsl:variable name="sRepOperWith-">
1176
						            <xsl:call-template name="SReplaceOperWithMinus">
1177
							              <xsl:with-param name="sToParse" select="$sRepNumWith0"/>
1178
						            </xsl:call-template>
1179
					          </xsl:variable>
1180

    
1181
					          <xsl:variable name="iFirstOper"
1182
                             select="string-length($sRepOperWith-) - string-length(substring-after($sRepOperWith-, '-'))"/>
1183
					          <xsl:variable name="iFirstNum"
1184
                             select="string-length($sRepOperWith-) - string-length(substring-after($sRepOperWith-, '0'))"/>
1185
					          <xsl:variable name="iFirstAmp"
1186
                             select="string-length($sRepOperWith-) - string-length(substring-after($sRepOperWith-, '&amp;'))"/>
1187
					          <xsl:variable name="fNumAtPos1">
1188
						            <xsl:choose>
1189
							              <xsl:when test="substring($sRepOperWith-,1,1)='0'">1</xsl:when>
1190
							              <xsl:otherwise>0</xsl:otherwise>
1191
						            </xsl:choose>
1192
					          </xsl:variable>
1193
					          <xsl:variable name="fOperAtPos1">
1194
						            <xsl:choose>
1195
							              <xsl:when test="substring($sRepOperWith-,1,1)='-'">1</xsl:when>
1196
							              <xsl:otherwise>0</xsl:otherwise>
1197
						            </xsl:choose>
1198
					          </xsl:variable>
1199
					          <xsl:choose>
1200

    
1201
						<!-- Case I: The string begins with neither a number, nor an operator -->
1202
						<xsl:when test="$fNumAtPos1='0' and $fOperAtPos1='0'">
1203
							              <mi>
1204
								                <xsl:call-template name="CreateTokenAttributes">
1205
									                  <xsl:with-param name="scr" select="$scr"/>
1206
									                  <xsl:with-param name="sty" select="$sty"/>
1207
									                  <xsl:with-param name="nor" select="$nor"/>
1208
									                  <xsl:with-param name="nCharToPrint" select="1"/>
1209
									                  <xsl:with-param name="sTokenType" select="'mi'"/>
1210
								                </xsl:call-template>
1211
								                <xsl:value-of select="substring($sToParse,1,1)"/>
1212
							              </mi>
1213
							              <xsl:call-template name="ParseEqArrMr">
1214
								                <xsl:with-param name="sToParse" select="substring($sToParse, 2)"/>
1215
								                <xsl:with-param name="scr" select="$scr"/>
1216
								                <xsl:with-param name="sty" select="$sty"/>
1217
								                <xsl:with-param name="nor" select="$nor"/>
1218
								                <xsl:with-param name="align" select="$align"/>
1219
							              </xsl:call-template>
1220
						            </xsl:when>
1221

    
1222
						            <!-- Case II: There is an operator at position 1 -->
1223
						<xsl:when test="$fOperAtPos1='1'">
1224
							              <mo>
1225
								                <xsl:call-template name="CreateTokenAttributes">
1226
									                  <xsl:with-param name="scr"/>
1227
									                  <xsl:with-param name="sty"/>
1228
									                  <xsl:with-param name="nor" select="$nor"/>
1229
									                  <xsl:with-param name="sTokenType" select="'mo'"/>
1230
								                </xsl:call-template>
1231
								                <xsl:value-of select="substring($sToParse,1,1)"/>
1232
							              </mo>
1233
							              <xsl:call-template name="ParseEqArrMr">
1234
								                <xsl:with-param name="sToParse" select="substring($sToParse, 2)"/>
1235
								                <xsl:with-param name="scr" select="$scr"/>
1236
								                <xsl:with-param name="sty" select="$sty"/>
1237
								                <xsl:with-param name="nor" select="$nor"/>
1238
								                <xsl:with-param name="align" select="$align"/>
1239
							              </xsl:call-template>
1240
						            </xsl:when>
1241

    
1242
						            <!-- Case III: There is a number at position 1 -->
1243
						<xsl:otherwise>
1244
							              <xsl:variable name="sConsecNum">
1245
								                <xsl:call-template name="SNumStart">
1246
									                  <xsl:with-param name="sToParse" select="$sToParse"/>
1247
									                  <xsl:with-param name="sPattern" select="$sRepNumWith0"/>
1248
								                </xsl:call-template>
1249
							              </xsl:variable>
1250
							              <mn>
1251
								                <xsl:call-template name="CreateTokenAttributes">
1252
									                  <xsl:with-param name="scr"/>
1253
									                  <xsl:with-param name="sty" select="'p'"/>
1254
									                  <xsl:with-param name="nor" select="$nor"/>
1255
									                  <xsl:with-param name="sTokenType" select="'mn'"/>
1256
								                </xsl:call-template>
1257
								                <xsl:value-of select="$sConsecNum"/>
1258
							              </mn>
1259
							              <xsl:call-template name="ParseEqArrMr">
1260
								                <xsl:with-param name="sToParse" select="substring-after($sToParse, $sConsecNum)"/>
1261
								                <xsl:with-param name="scr" select="$scr"/>
1262
								                <xsl:with-param name="sty" select="$sty"/>
1263
								                <xsl:with-param name="nor" select="$nor"/>
1264
								                <xsl:with-param name="align" select="$align"/>
1265
							              </xsl:call-template>
1266
						            </xsl:otherwise>
1267
					          </xsl:choose>
1268
				        </xsl:otherwise>
1269
			      </xsl:choose>
1270
		    </xsl:if>
1271
	  </xsl:template>
1272

    
1273
	  <!-- %%Template: ParseMt
1274

    
1275
			Produce a run of text. Technically, OMML makes no distinction 
1276
			between numbers, operators, and other characters in a run. For 
1277
			MathML we need to break these into mi, mn, or mo elements. 
1278
			
1279
			See also ParseEqArrMr
1280
	-->
1281
	<xsl:template name="ParseMt">
1282
		    <xsl:param name="sToParse"/>
1283
		    <xsl:param name="sty"/>
1284
		    <xsl:param name="scr"/>
1285
		    <xsl:param name="nor"/>
1286
		    <xsl:if test="string-length($sToParse) &gt; 0">
1287
			      <xsl:variable name="sRepNumWith0">
1288
				        <xsl:call-template name="SReplaceNumWithZero">
1289
					          <xsl:with-param name="sToParse" select="$sToParse"/>
1290
				        </xsl:call-template>
1291
			      </xsl:variable>
1292
			      <xsl:variable name="sRepOperWith-">
1293
				        <xsl:call-template name="SReplaceOperWithMinus">
1294
					          <xsl:with-param name="sToParse" select="$sRepNumWith0"/>
1295
				        </xsl:call-template>
1296
			      </xsl:variable>
1297

    
1298
			      <xsl:variable name="iFirstOper"
1299
                       select="string-length($sRepOperWith-) - string-length(substring-after($sRepOperWith-, '-'))"/>
1300
			      <xsl:variable name="iFirstNum"
1301
                       select="string-length($sRepOperWith-) - string-length(substring-after($sRepOperWith-, '0'))"/>
1302
			      <xsl:variable name="fNumAtPos1">
1303
				        <xsl:choose>
1304
					          <xsl:when test="substring($sRepOperWith-,1,1)='0'">1</xsl:when>
1305
					          <xsl:otherwise>0</xsl:otherwise>
1306
				        </xsl:choose>
1307
			      </xsl:variable>
1308
			      <xsl:variable name="fOperAtPos1">
1309
				        <xsl:choose>
1310
					          <xsl:when test="substring($sRepOperWith-,1,1)='-'">1</xsl:when>
1311
					          <xsl:otherwise>0</xsl:otherwise>
1312
				        </xsl:choose>
1313
			      </xsl:variable>
1314

    
1315
			      <xsl:choose>
1316

    
1317
				<!-- Case I: The string begins with neither a number, nor an operator -->
1318
				<xsl:when test="$fOperAtPos1='0' and $fNumAtPos1='0'">
1319
					          <xsl:variable name="nCharToPrint">
1320
						            <xsl:choose>
1321
							              <xsl:when test="ancestor::m:fName">
1322
								                <xsl:choose>
1323
									                  <xsl:when test="($iFirstOper=$iFirstNum) and             ($iFirstOper=string-length($sToParse)) and                        (substring($sRepOperWith-, string-length($sRepOperWith-))!='0') and                         (substring($sRepOperWith-, string-length($sRepOperWith-))!='-')">
1324
										                    <xsl:value-of select="string-length($sToParse)"/>
1325
									                  </xsl:when>
1326
									                  <xsl:when test="$iFirstOper &lt; $iFirstNum">
1327
										                    <xsl:value-of select="$iFirstOper - 1"/>
1328
									                  </xsl:when>
1329
									                  <xsl:otherwise>
1330
										                    <xsl:value-of select="$iFirstNum - 1"/>
1331
									                  </xsl:otherwise>
1332
								                </xsl:choose>
1333
							              </xsl:when>
1334
							              <xsl:otherwise>1</xsl:otherwise>
1335
						            </xsl:choose>
1336
					          </xsl:variable>
1337

    
1338
					          <mi>
1339
						            <xsl:call-template name="CreateTokenAttributes">
1340
							              <xsl:with-param name="scr" select="$scr"/>
1341
							              <xsl:with-param name="sty" select="$sty"/>
1342
							              <xsl:with-param name="nor" select="$nor"/>
1343
							              <xsl:with-param name="nCharToPrint" select="$nCharToPrint"/>
1344
							              <xsl:with-param name="sTokenType" select="'mi'"/>
1345
						            </xsl:call-template>
1346
						            <xsl:value-of select="substring($sToParse, 1, $nCharToPrint)"/>
1347
					          </mi>
1348
					          <xsl:call-template name="ParseMt">
1349
						            <xsl:with-param name="sToParse" select="substring($sToParse, $nCharToPrint+1)"/>
1350
						            <xsl:with-param name="scr" select="$scr"/>
1351
						            <xsl:with-param name="sty" select="$sty"/>
1352
						            <xsl:with-param name="nor" select="$nor"/>
1353
					          </xsl:call-template>
1354
				        </xsl:when>
1355

    
1356
				        <!-- Case II: There is an operator at position 1 -->
1357
				<xsl:when test="$fOperAtPos1='1'">
1358
					          <mo>
1359
						            <xsl:call-template name="CreateTokenAttributes">
1360
							              <xsl:with-param name="scr"/>
1361
							              <xsl:with-param name="sty"/>
1362
							              <xsl:with-param name="nor" select="$nor"/>
1363
							              <xsl:with-param name="sTokenType" select="'mo'"/>
1364
						            </xsl:call-template>
1365
						            <xsl:value-of select="substring($sToParse,1,1)"/>
1366
					          </mo>
1367
					          <xsl:call-template name="ParseMt">
1368
						            <xsl:with-param name="sToParse" select="substring($sToParse, 2)"/>
1369
						            <xsl:with-param name="scr" select="$scr"/>
1370
						            <xsl:with-param name="sty" select="$sty"/>
1371
						            <xsl:with-param name="nor" select="$nor"/>
1372
					          </xsl:call-template>
1373
				        </xsl:when>
1374

    
1375
				        <!-- Case III: There is a number at position 1 -->
1376
				<xsl:otherwise>
1377
					          <xsl:variable name="sConsecNum">
1378
						            <xsl:call-template name="SNumStart">
1379
							              <xsl:with-param name="sToParse" select="$sToParse"/>
1380
							              <xsl:with-param name="sPattern" select="$sRepNumWith0"/>
1381
						            </xsl:call-template>
1382
					          </xsl:variable>
1383
					          <mn>
1384
						            <xsl:call-template name="CreateTokenAttributes">
1385
							              <xsl:with-param name="scr" select="$scr"/>
1386
							              <xsl:with-param name="sty" select="'p'"/>
1387
							              <xsl:with-param name="nor" select="$nor"/>
1388
							              <xsl:with-param name="sTokenType" select="'mn'"/>
1389
						            </xsl:call-template>
1390
						            <xsl:value-of select="$sConsecNum"/>
1391
					          </mn>
1392
					          <xsl:call-template name="ParseMt">
1393
						            <xsl:with-param name="sToParse" select="substring-after($sToParse, $sConsecNum)"/>
1394
						            <xsl:with-param name="scr" select="$scr"/>
1395
						            <xsl:with-param name="sty" select="$sty"/>
1396
						            <xsl:with-param name="nor" select="$nor"/>
1397
					          </xsl:call-template>
1398
				        </xsl:otherwise>
1399
			      </xsl:choose>
1400
		    </xsl:if>
1401
	  </xsl:template>
1402

    
1403
	  <!-- %%Template: SNumStart 
1404
	
1405
		Return the longest substring of sToParse starting from the 
1406
		start of sToParse that is a number. In addition, it takes the
1407
		pattern string, which is sToParse with all of its numbers 
1408
		replaced with a 0. sPattern should be the same length 
1409
		as sToParse		
1410
	-->
1411
	<xsl:template name="SNumStart">
1412
		    <xsl:param name="sToParse" select="''"/>
1413
		    <!-- if we don't get anything, take the string itself -->
1414
		<xsl:param name="sPattern" select="'$sToParse'"/>
1415

    
1416

    
1417
		    <xsl:choose>
1418
			<!-- the pattern says this is a number, recurse with the rest -->
1419
			<xsl:when test="substring($sPattern, 1, 1) = '0'">
1420
				        <xsl:call-template name="SNumStart">
1421
					          <xsl:with-param name="sToParse" select="$sToParse"/>
1422
					          <xsl:with-param name="sPattern" select="substring($sPattern, 2)"/>
1423
				        </xsl:call-template>
1424
			      </xsl:when>
1425

    
1426
			      <!-- the pattern says we've run out of numbers. Take as many
1427
				characters from sToParse as we shaved off sPattern -->
1428
			<xsl:otherwise>
1429
				        <xsl:value-of select="substring($sToParse, 1, string-length($sToParse) - string-length($sPattern))"/>
1430
			      </xsl:otherwise>
1431
		    </xsl:choose>
1432
	  </xsl:template>
1433

    
1434
	  <!-- %%Template SRepeatCharAcc
1435
	
1436
			The core of SRepeatChar with an accumulator. The current
1437
			string is in param $acc, and we will double and recurse,
1438
			if we're less than half of the required length or else just 
1439
			add the right amount of characters to the accumulator and
1440
			return
1441
	-->
1442
	<xsl:template name="SRepeatCharAcc">
1443
		    <xsl:param name="cchRequired" select="1"/>
1444
		    <xsl:param name="ch" select="'-'"/>
1445
		    <xsl:param name="acc" select="$ch"/>
1446

    
1447
		    <xsl:variable name="cchAcc" select="string-length($acc)"/>
1448
		    <xsl:choose>
1449
			      <xsl:when test="(2 * $cchAcc) &lt; $cchRequired">
1450
				        <xsl:call-template name="SRepeatCharAcc">
1451
					          <xsl:with-param name="cchRequired" select="$cchRequired"/>
1452
					          <xsl:with-param name="ch" select="$ch"/>
1453
					          <xsl:with-param name="acc" select="concat($acc, $acc)"/>
1454
				        </xsl:call-template>
1455
			      </xsl:when>
1456

    
1457
			      <xsl:otherwise>
1458
				        <xsl:value-of select="concat($acc, substring($acc, 1, $cchRequired - $cchAcc))"/>
1459
			      </xsl:otherwise>
1460
		    </xsl:choose>
1461
	  </xsl:template>
1462

    
1463

    
1464
	  <!-- %%Template SRepeatChar
1465
	
1466
			Generates a string nchRequired long by repeating the given character ch
1467
	-->
1468
	<xsl:template name="SRepeatChar">
1469
		    <xsl:param name="cchRequired" select="1"/>
1470
		    <xsl:param name="ch" select="'-'"/>
1471

    
1472
		    <xsl:call-template name="SRepeatCharAcc">
1473
			      <xsl:with-param name="cchRequired" select="$cchRequired"/>
1474
			      <xsl:with-param name="ch" select="$ch"/>
1475
			      <xsl:with-param name="acc" select="$ch"/>
1476
		    </xsl:call-template>
1477
	  </xsl:template>
1478

    
1479
	  <!-- %%Template SReplaceOperWithMinus
1480
	
1481
		Go through the given string and replace every instance
1482
		of an operator with a minus '-'. This helps quickly identify
1483
		the first instance of an operator.  
1484
	-->
1485
	<xsl:template name="SReplaceOperWithMinus">
1486
		    <xsl:param name="sToParse" select="''"/>
1487

    
1488
		    <xsl:value-of select="translate($sToParse, $sOperators, $sMinuses)"/>
1489
	  </xsl:template>
1490

    
1491
	  <!-- %%Template SReplaceNumWithZero
1492
	
1493
		Go through the given string and replace every instance
1494
		of an number with a zero '0'. This helps quickly identify
1495
		the first occurence of a number. 
1496
		
1497
		Considers the '.' and ',' part of a number iff they are sandwiched 
1498
		between two other numbers. 0.3 will be recognized as a number,
1499
		x.3 will not be. Since these characters can also be an operator, this 
1500
		should be called before SReplaceOperWithMinus.
1501
	-->
1502
	<xsl:template name="SReplaceNumWithZero">
1503
		    <xsl:param name="sToParse" select="''"/>
1504

    
1505
		    <!-- First do a simple replace. Numbers will all be come 0's.
1506
			After this point, the pattern involving the . or , that 
1507
			we are looking for will become 0.0 or 0,0 -->
1508
		<xsl:variable name="sSimpleReplace" select="translate($sToParse, $sNumbers, $sZeros)"/>
1509

    
1510
		    <!-- And then, replace 0.0 with just 000. This means that the . will 
1511
			become part of the number -->
1512
		<xsl:variable name="sReplacePeriod">
1513
			      <xsl:call-template name="SReplace">
1514
				        <xsl:with-param name="sInput" select="$sSimpleReplace"/>
1515
				        <xsl:with-param name="sOrig" select="'0.0'"/>
1516
				        <xsl:with-param name="sReplacement" select="'000'"/>
1517
			      </xsl:call-template>
1518
		    </xsl:variable>
1519

    
1520
		    <!-- And then, replace 0,0 with just 000. This means that the , will 
1521
			become part of the number -->
1522
		<xsl:call-template name="SReplace">
1523
			      <xsl:with-param name="sInput" select="$sReplacePeriod"/>
1524
			      <xsl:with-param name="sOrig" select="'0,0'"/>
1525
			      <xsl:with-param name="sReplacement" select="'000'"/>
1526
		    </xsl:call-template>
1527
	  </xsl:template>
1528

    
1529
	  <!-- Template to translate Word's borderBox properties into the menclose notation attribute
1530
       The initial call to this SHOULD NOT pass an sAttribute.  Subsequent calls to 
1531
       CreateMencloseNotationAttrFromBorderBoxAttr by CreateMencloseNotationAttrFromBorderBoxAttr will
1532
       update the sAttribute as appropriate.
1533
       
1534
       CreateMencloseNotationAttrFromBorderBoxAttr looks at each attribute (fHideTop, fHideBot, etc.) one at a time
1535
       in the order they are listed and passes a modified sAttribute to CreateMencloseNotationAttrFromBorderBoxAttr.
1536
       Each successive call to CreateMencloseNotationAttrFromBorderBoxAttr knows which attribute to look at because 
1537
       the previous call should have omitted passing the attribute it just analyzed.  This is why as you read lower 
1538
       and lower in the template that each call to CreateMencloseNotationAttrFromBorderBoxAttr has fewer and fewer attributes.
1539
       -->
1540
	<xsl:template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1541
		    <xsl:param name="fHideTop"/>
1542
		    <xsl:param name="fHideBot"/>
1543
		    <xsl:param name="fHideLeft"/>
1544
		    <xsl:param name="fHideRight"/>
1545
		    <xsl:param name="fStrikeH"/>
1546
		    <xsl:param name="fStrikeV"/>
1547
		    <xsl:param name="fStrikeBLTR"/>
1548
		    <xsl:param name="fStrikeTLBR"/>
1549
		    <xsl:param name="sAttribute"/>
1550

    
1551
		    <xsl:choose>
1552
			      <xsl:when test="string-length($sAttribute) = 0">
1553
				        <xsl:choose>
1554
					          <xsl:when test="string-length($fHideTop) &gt; 0                       and string-length($fHideBot) &gt; 0                        and string-length($fHideLeft) &gt; 0                       and string-length($fHideRight) &gt; 0">
1555

    
1556
						            <xsl:choose>
1557
							              <xsl:when test="$fHideTop = 0                                and $fHideBot = 0                               and $fHideLeft = 0                                and $fHideRight = 0">
1558
								<!-- We can use 'box' instead of top, bot, left, and right.  Therefore,
1559
                  replace sAttribute with 'box' and begin analyzing params fStrikeH
1560
                  and below. -->
1561
								<xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1562
									                  <xsl:with-param name="fStrikeH" select="$fStrikeH"/>
1563
									                  <xsl:with-param name="fStrikeV" select="$fStrikeV"/>
1564
									                  <xsl:with-param name="fStrikeBLTR" select="$fStrikeBLTR"/>
1565
									                  <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR"/>
1566
									                  <xsl:with-param name="sAttribute">
1567
										                    <xsl:text>box</xsl:text>
1568
									                  </xsl:with-param>
1569
								                </xsl:call-template>
1570
							              </xsl:when>
1571
							              <xsl:otherwise>
1572
								<!-- Can't use 'box', theremore, must analyze all attributes -->
1573
								<xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1574
									                  <xsl:with-param name="fHideTop" select="$fHideTop"/>
1575
									                  <xsl:with-param name="fHideBot" select="$fHideBot"/>
1576
									                  <xsl:with-param name="fHideLeft" select="$fHideLeft"/>
1577
									                  <xsl:with-param name="fHideRight" select="$fHideRight"/>
1578
									                  <xsl:with-param name="fStrikeH" select="$fStrikeH"/>
1579
									                  <xsl:with-param name="fStrikeV" select="$fStrikeV"/>
1580
									                  <xsl:with-param name="fStrikeBLTR" select="$fStrikeBLTR"/>
1581
									                  <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR"/>
1582
									                  <xsl:with-param name="sAttribute">
1583
										<!-- Assume using all four (left right top bottom).  Subsequent calls
1584
                         will remove the sides which aren't to be includes. -->
1585
										<xsl:text>left right top bottom</xsl:text>
1586
									                  </xsl:with-param>
1587
								                </xsl:call-template>
1588
							              </xsl:otherwise>
1589
						            </xsl:choose>
1590
					          </xsl:when>
1591
				        </xsl:choose>
1592
			      </xsl:when>
1593
			      <xsl:otherwise>
1594
				        <xsl:choose>
1595
					          <xsl:when test="string-length($fHideTop) &gt; 0">
1596
						            <xsl:choose>
1597
							              <xsl:when test="$fHideTop=1">
1598
								                <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1599
									                  <xsl:with-param name="fHideBot" select="$fHideBot"/>
1600
									                  <xsl:with-param name="fHideLeft" select="$fHideLeft"/>
1601
									                  <xsl:with-param name="fHideRight" select="$fHideRight"/>
1602
									                  <xsl:with-param name="fStrikeH" select="$fStrikeH"/>
1603
									                  <xsl:with-param name="fStrikeV" select="$fStrikeV"/>
1604
									                  <xsl:with-param name="fStrikeBLTR" select="$fStrikeBLTR"/>
1605
									                  <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR"/>
1606
									                  <xsl:with-param name="sAttribute">
1607
										                    <xsl:call-template name="SReplace">
1608
											                      <xsl:with-param name="sInput" select="$sAttribute"/>
1609
											                      <xsl:with-param name="sOrig" select="'top'"/>
1610
											                      <xsl:with-param name="sReplacement" select="''"/>
1611
										                    </xsl:call-template>
1612
									                  </xsl:with-param>
1613
								                </xsl:call-template>
1614
							              </xsl:when>
1615
							              <xsl:otherwise>
1616
								                <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1617
									                  <xsl:with-param name="fHideBot" select="$fHideBot"/>
1618
									                  <xsl:with-param name="fHideLeft" select="$fHideLeft"/>
1619
									                  <xsl:with-param name="fHideRight" select="$fHideRight"/>
1620
									                  <xsl:with-param name="fStrikeH" select="$fStrikeH"/>
1621
									                  <xsl:with-param name="fStrikeV" select="$fStrikeV"/>
1622
									                  <xsl:with-param name="fStrikeBLTR" select="$fStrikeBLTR"/>
1623
									                  <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR"/>
1624
									                  <xsl:with-param name="sAttribute" select="$sAttribute"/>
1625
								                </xsl:call-template>
1626
							              </xsl:otherwise>
1627
						            </xsl:choose>
1628
					          </xsl:when>
1629
					          <xsl:when test="string-length($fHideBot) &gt; 0">
1630
						            <xsl:choose>
1631
							              <xsl:when test="$fHideBot=1">
1632
								                <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1633
									                  <xsl:with-param name="fHideLeft" select="$fHideLeft"/>
1634
									                  <xsl:with-param name="fHideRight" select="$fHideRight"/>
1635
									                  <xsl:with-param name="fStrikeH" select="$fStrikeH"/>
1636
									                  <xsl:with-param name="fStrikeV" select="$fStrikeV"/>
1637
									                  <xsl:with-param name="fStrikeBLTR" select="$fStrikeBLTR"/>
1638
									                  <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR"/>
1639
									                  <xsl:with-param name="sAttribute">
1640
										                    <xsl:call-template name="SReplace">
1641
											                      <xsl:with-param name="sInput" select="$sAttribute"/>
1642
											                      <xsl:with-param name="sOrig" select="'bottom'"/>
1643
											                      <xsl:with-param name="sReplacement" select="''"/>
1644
										                    </xsl:call-template>
1645
									                  </xsl:with-param>
1646
								                </xsl:call-template>
1647
							              </xsl:when>
1648
							              <xsl:otherwise>
1649
								                <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1650
									                  <xsl:with-param name="fHideLeft" select="$fHideLeft"/>
1651
									                  <xsl:with-param name="fHideRight" select="$fHideRight"/>
1652
									                  <xsl:with-param name="fStrikeH" select="$fStrikeH"/>
1653
									                  <xsl:with-param name="fStrikeV" select="$fStrikeV"/>
1654
									                  <xsl:with-param name="fStrikeBLTR" select="$fStrikeBLTR"/>
1655
									                  <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR"/>
1656
									                  <xsl:with-param name="sAttribute" select="$sAttribute"/>
1657
								                </xsl:call-template>
1658
							              </xsl:otherwise>
1659
						            </xsl:choose>
1660
					          </xsl:when>
1661
					          <xsl:when test="string-length($fHideLeft) &gt; 0">
1662
						            <xsl:choose>
1663
							              <xsl:when test="$fHideLeft=1">
1664
								                <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1665
									                  <xsl:with-param name="fHideRight" select="$fHideRight"/>
1666
									                  <xsl:with-param name="fStrikeH" select="$fStrikeH"/>
1667
									                  <xsl:with-param name="fStrikeV" select="$fStrikeV"/>
1668
									                  <xsl:with-param name="fStrikeBLTR" select="$fStrikeBLTR"/>
1669
									                  <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR"/>
1670
									                  <xsl:with-param name="sAttribute">
1671
										                    <xsl:call-template name="SReplace">
1672
											                      <xsl:with-param name="sInput" select="$sAttribute"/>
1673
											                      <xsl:with-param name="sOrig" select="'left'"/>
1674
											                      <xsl:with-param name="sReplacement" select="''"/>
1675
										                    </xsl:call-template>
1676
									                  </xsl:with-param>
1677
								                </xsl:call-template>
1678
							              </xsl:when>
1679
							              <xsl:otherwise>
1680
								                <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1681
									                  <xsl:with-param name="fHideRight" select="$fHideRight"/>
1682
									                  <xsl:with-param name="fStrikeH" select="$fStrikeH"/>
1683
									                  <xsl:with-param name="fStrikeV" select="$fStrikeV"/>
1684
									                  <xsl:with-param name="fStrikeBLTR" select="$fStrikeBLTR"/>
1685
									                  <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR"/>
1686
									                  <xsl:with-param name="sAttribute" select="$sAttribute"/>
1687
								                </xsl:call-template>
1688
							              </xsl:otherwise>
1689
						            </xsl:choose>
1690
					          </xsl:when>
1691
					          <xsl:when test="string-length($fHideRight) &gt; 0">
1692
						            <xsl:choose>
1693
							              <xsl:when test="$fHideRight=1">
1694
								                <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1695
									                  <xsl:with-param name="fStrikeH" select="$fStrikeH"/>
1696
									                  <xsl:with-param name="fStrikeV" select="$fStrikeV"/>
1697
									                  <xsl:with-param name="fStrikeBLTR" select="$fStrikeBLTR"/>
1698
									                  <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR"/>
1699
									                  <xsl:with-param name="sAttribute">
1700
										                    <xsl:call-template name="SReplace">
1701
											                      <xsl:with-param name="sInput" select="$sAttribute"/>
1702
											                      <xsl:with-param name="sOrig" select="'right'"/>
1703
											                      <xsl:with-param name="sReplacement" select="''"/>
1704
										                    </xsl:call-template>
1705
									                  </xsl:with-param>
1706
								                </xsl:call-template>
1707
							              </xsl:when>
1708
							              <xsl:otherwise>
1709
								                <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1710
									                  <xsl:with-param name="fStrikeH" select="$fStrikeH"/>
1711
									                  <xsl:with-param name="fStrikeV" select="$fStrikeV"/>
1712
									                  <xsl:with-param name="fStrikeBLTR" select="$fStrikeBLTR"/>
1713
									                  <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR"/>
1714
									                  <xsl:with-param name="sAttribute" select="$sAttribute"/>
1715
								                </xsl:call-template>
1716
							              </xsl:otherwise>
1717
						            </xsl:choose>
1718
					          </xsl:when>
1719
					          <xsl:when test="string-length($fStrikeH) &gt; 0">
1720
						            <xsl:choose>
1721
							              <xsl:when test="$fStrikeH=1">
1722
								                <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1723
									                  <xsl:with-param name="fStrikeV" select="$fStrikeV"/>
1724
									                  <xsl:with-param name="fStrikeBLTR" select="$fStrikeBLTR"/>
1725
									                  <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR"/>
1726
									                  <xsl:with-param name="sAttribute" select="concat($sAttribute, ' horizontalstrike')"/>
1727
								                </xsl:call-template>
1728
							              </xsl:when>
1729
							              <xsl:otherwise>
1730
								                <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1731
									                  <xsl:with-param name="fStrikeV" select="$fStrikeV"/>
1732
									                  <xsl:with-param name="fStrikeBLTR" select="$fStrikeBLTR"/>
1733
									                  <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR"/>
1734
									                  <xsl:with-param name="sAttribute" select="$sAttribute"/>
1735
								                </xsl:call-template>
1736
							              </xsl:otherwise>
1737
						            </xsl:choose>
1738
					          </xsl:when>
1739
					          <xsl:when test="string-length($fStrikeV) &gt; 0">
1740
						            <xsl:choose>
1741
							              <xsl:when test="$fStrikeV=1">
1742
								                <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1743
									                  <xsl:with-param name="fStrikeBLTR" select="$fStrikeBLTR"/>
1744
									                  <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR"/>
1745
									                  <xsl:with-param name="sAttribute" select="concat($sAttribute, ' verticalstrike')"/>
1746
								                </xsl:call-template>
1747
							              </xsl:when>
1748
							              <xsl:otherwise>
1749
								                <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1750
									                  <xsl:with-param name="fStrikeBLTR" select="$fStrikeBLTR"/>
1751
									                  <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR"/>
1752
									                  <xsl:with-param name="sAttribute" select="$sAttribute"/>
1753
								                </xsl:call-template>
1754
							              </xsl:otherwise>
1755
						            </xsl:choose>
1756
					          </xsl:when>
1757
					          <xsl:when test="string-length($fStrikeBLTR) &gt; 0">
1758
						            <xsl:choose>
1759
							              <xsl:when test="$fStrikeBLTR=1">
1760
								                <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1761
									                  <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR"/>
1762
									                  <xsl:with-param name="sAttribute" select="concat($sAttribute, ' updiagonalstrike')"/>
1763
								                </xsl:call-template>
1764
							              </xsl:when>
1765
							              <xsl:otherwise>
1766
								                <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1767
									                  <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR"/>
1768
									                  <xsl:with-param name="sAttribute" select="$sAttribute"/>
1769
								                </xsl:call-template>
1770
							              </xsl:otherwise>
1771
						            </xsl:choose>
1772
					          </xsl:when>
1773
					          <xsl:when test="string-length($fStrikeTLBR) &gt; 0">
1774
						            <xsl:choose>
1775
							              <xsl:when test="$fStrikeTLBR=1">
1776
								                <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1777
									                  <xsl:with-param name="sAttribute" select="concat($sAttribute, ' downdiagonalstrike')"/>
1778
								                </xsl:call-template>
1779
							              </xsl:when>
1780
							              <xsl:otherwise>
1781
								                <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1782
									                  <xsl:with-param name="sAttribute" select="$sAttribute"/>
1783
								                </xsl:call-template>
1784
							              </xsl:otherwise>
1785
						            </xsl:choose>
1786
					          </xsl:when>
1787
					          <xsl:otherwise>
1788
						            <xsl:attribute name="notation">
1789
							              <xsl:value-of select="normalize-space($sAttribute)"/>
1790
						            </xsl:attribute>
1791
					          </xsl:otherwise>
1792
				        </xsl:choose>
1793
			      </xsl:otherwise>
1794
		    </xsl:choose>
1795
	  </xsl:template>
1796

    
1797

    
1798
	  <xsl:template name="checkDirectFormatting">
1799
	    <xsl:if test="w:rPr/w:rFonts/@w:ascii and not(w:rPr/w:rFonts/@w:ascii='Cambria Math')">
1800
	      <xsl:attribute name="fontfamily" select="w:rPr/w:rFonts/@w:ascii"/>
1801
	    </xsl:if>
1802
	    <xsl:choose>
1803
	      <xsl:when test="w:rPr/w:b[not(@w:val='0')]">
1804
		<xsl:attribute name="fontweight">bold</xsl:attribute>
1805
	      </xsl:when>
1806
	      <xsl:when test="w:rPr/w:b[@w:val='0']">
1807
		<xsl:attribute name="fontweight">normal</xsl:attribute>
1808
	      </xsl:when>
1809
	    </xsl:choose>
1810
	    <xsl:choose>
1811
	      <xsl:when test="w:rPr/w:i[not(@w:val='0')]">
1812
		<xsl:attribute name="fontstyle">italic</xsl:attribute>
1813
	      </xsl:when>
1814
	      <xsl:when test="w:rPr/w:i[@w:val='0']">
1815
		<xsl:attribute name="fontstyle">upright</xsl:attribute>
1816
	      </xsl:when>
1817
	    </xsl:choose>
1818
	  </xsl:template>
1819
</xsl:stylesheet>