summaryrefslogtreecommitdiff
path: root/contrib/xslt/mathml.xsl
blob: dc386d34573377961d237fde16f279345b38c025 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet
		version="1.0"
		xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
		xmlns:math="math">

	<xsl:template match="/">
		<xsl:apply-templates select="/document/math:math"/>
	</xsl:template>

	<xsl:template match="/document/math:math">
		<xsl:element name="math" namespace="http://www.w3.org/1998/Math/MathML">
			<xsl:apply-templates select="math:*"/>
		</xsl:element>
	</xsl:template>

	<xsl:template match="math:equation">
		<!--<xsl:element name="mtr" namespace="http://www.w3.org/1998/Math/MathML">-->
			<xsl:apply-templates select="math:field"/>
		<!--</xsl:element>-->
	</xsl:template>

	<xsl:template match="math:field">
		<xsl:element name="mrow" namespace="http://www.w3.org/1998/Math/MathML">
			<xsl:apply-templates select="math:*"/>
		</xsl:element>
	</xsl:template>

	<xsl:template match="math:power">
		<xsl:element name="msup" namespace="http://www.w3.org/1998/Math/MathML">
			<xsl:apply-templates select="math:*"/>
		</xsl:element>
	</xsl:template>

	<xsl:template match="math:index">
		<xsl:element name="msub" namespace="http://www.w3.org/1998/Math/MathML">
			<xsl:apply-templates select="math:*"/>
		</xsl:element>
	</xsl:template>

	<!-- Operators -->

	<xsl:template match="math:equals">
		<xsl:element name="mo" namespace="http://www.w3.org/1998/Math/MathML">
			<xsl:text>=</xsl:text>
		</xsl:element>
	</xsl:template>

	<xsl:template match="math:plus">
		<xsl:element name="mo" namespace="http://www.w3.org/1998/Math/MathML">
			<xsl:text>+</xsl:text>
		</xsl:element>
	</xsl:template>

	<xsl:template match="math:minus">
		<xsl:element name="mo" namespace="http://www.w3.org/1998/Math/MathML">
			<xsl:text>-</xsl:text>
		</xsl:element>
	</xsl:template>

	<xsl:template match="math:ast">
		<xsl:element name="mo" namespace="http://www.w3.org/1998/Math/MathML">
			<xsl:text>*</xsl:text>
		</xsl:element>
	</xsl:template>

	<!-- Leaf elements -->

	<xsl:template match="math:number">
		<xsl:element name="mn" namespace="http://www.w3.org/1998/Math/MathML">
			<xsl:value-of select="."/>
		</xsl:element>
	</xsl:template>

	<xsl:template match="math:text">
		<xsl:element name="mtext" namespace="http://www.w3.org/1998/Math/MathML">
			<xsl:value-of select="."/>
		</xsl:element>
	</xsl:template>

	<xsl:template match="math:var">
		<xsl:element name="mi" namespace="http://www.w3.org/1998/Math/MathML">
			<xsl:value-of select="."/>
		</xsl:element>
	</xsl:template>

	<xsl:template math="* msup">
		
	</xsl:template>

</xsl:stylesheet>