]> matita.cs.unibo.it Git - helm.git/blob - helm/DEVEL/mathml_editor/xsl/tml-tex.xsl
* added show/hide cursro methods
[helm.git] / helm / DEVEL / mathml_editor / xsl / tml-tex.xsl
1 <?xml version="1.0"?>
2
3 <xsl:stylesheet
4      xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
5      xmlns:tml="http://helm.cs.unibo.it/2002/TML"
6      xmlns:m="http://www.w3.org/1998/Math/MathML"
7      version="1.0">
8
9   <xsl:output method="text" indent="yes"/>
10
11   <xsl:param name="id" select="/.."/>
12
13   <xsl:template match="/">
14     <xsl:choose>
15       <xsl:when test="$id">
16         <xsl:apply-templates select="descendant::*[@id=$id]"/>
17       </xsl:when>
18       <xsl:otherwise>
19         <xsl:apply-templates select="*"/>
20       </xsl:otherwise>
21     </xsl:choose>
22   </xsl:template>
23
24   <xsl:template match="tml:tex">
25     <xsl:apply-templates select="*"/>
26   </xsl:template>
27
28   <xsl:template match="tml:math">
29     <xsl:choose>
30       <xsl:when test="@display='1'">$$<xsl:apply-templates select="*"/>$$</xsl:when>
31       <xsl:otherwise>$<xsl:apply-templates select="*"/>$</xsl:otherwise>
32     </xsl:choose>
33   </xsl:template>
34
35   <xsl:template match="tml:i">
36     <xsl:choose>
37       <xsl:when test="@name">\<xsl:value-of select="@name"/>
38         <xsl:if test="parent::tml:g and following-sibling::tml:i"><xsl:value-of select="' '"/></xsl:if>
39       </xsl:when>
40       <xsl:when test="string-length(@val)=1"><xsl:value-of select="@val"/></xsl:when>
41       <xsl:otherwise>{\it <xsl:value-of select="@val"/>}</xsl:otherwise>
42     </xsl:choose>
43   </xsl:template>
44
45   <xsl:template match="tml:n">
46     <xsl:choose>
47       <xsl:when test="@name">\<xsl:value-of select="@name"/>
48         <xsl:if test="parent::tml:g and following-sibling::tml:n"><xsl:value-of select="' '"/></xsl:if>
49       </xsl:when>
50       <xsl:when test="string-length(@val)=1"><xsl:value-of select="@val"/></xsl:when>
51       <xsl:otherwise>{\rm <xsl:value-of select="@val"/>}</xsl:otherwise>
52     </xsl:choose>
53   </xsl:template>
54
55   <xsl:template match="tml:o">
56     <xsl:choose>
57       <xsl:when test="@name">\<xsl:value-of select="@name"/><xsl:value-of select="' '"/></xsl:when>
58       <xsl:when test="string-length(@val)=1"><xsl:value-of select="@val"/></xsl:when>
59       <xsl:otherwise><xsl:value-of select="@val"/></xsl:otherwise>
60     </xsl:choose>
61   </xsl:template>
62
63   <xsl:template match="tml:sb">
64     <xsl:choose>
65       <xsl:when test="@under='1'">
66         <xsl:apply-templates select="*[1]"/>__<xsl:apply-templates select="*[2]"/>
67       </xsl:when>
68       <xsl:otherwise>
69         <xsl:apply-templates select="*[1]"/>_<xsl:apply-templates select="*[2]"/>
70       </xsl:otherwise>
71     </xsl:choose>
72   </xsl:template>
73
74   <xsl:template match="tml:sp">
75     <xsl:choose>
76       <xsl:when test="@over='1'">
77         <xsl:apply-templates select="*[1]"/>^^<xsl:apply-templates select="*[2]"/>
78       </xsl:when>
79       <xsl:otherwise>
80         <xsl:apply-templates select="*[1]"/>^<xsl:apply-templates select="*[2]"/>
81       </xsl:otherwise>
82     </xsl:choose>
83   </xsl:template>
84
85   <xsl:template match="tml:g[@id]">{<xsl:apply-templates select="*"/>}</xsl:template>
86
87   <xsl:template match="tml:g">
88     <xsl:apply-templates select="*"/>
89   </xsl:template>
90
91   <xsl:template match="tml:row">
92     <xsl:apply-templates select="cell"/>\cr </xsl:template>
93
94   <xsl:template match="tml:cell">
95     <xsl:apply-templates select="*"/>
96     <xsl:if test="position() &lt; last()">&amp;</xsl:if>
97   </xsl:template>
98
99 <!--/// CONTROL SEQUENCES ///-->
100
101   <xsl:template match="tml:c[*[1][self::tml:g[@left-open='1']]]">
102     <xsl:apply-templates select="*[1]"/>\<xsl:value-of select="@name"/>
103     <xsl:if test="*[2][self::tml:i]"><xsl:value-of select="' '"/></xsl:if>
104     <xsl:apply-templates select="*[position()&gt;1]"/>
105   </xsl:template>
106
107   <xsl:template match="tml:c">\<xsl:value-of select="@name"/>
108     <xsl:if test="*[1][self::tml:i]"><xsl:value-of select="' '"/></xsl:if>
109     <xsl:apply-templates select="*"/>
110   </xsl:template>
111
112 </xsl:stylesheet>
113