3 Copyright (C) 2002-2003, Luca Padovani <luca.padovani@cs.unibo.it>,
4 2003, Paolo Marinelli <pmarinel@cs.unibo.it>.
6 This file is part of EdiTeX, an editor of mathematical
7 expressions based on TeX syntax
9 EdiTeX is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License
11 as published by the Free Software Foundation; either version 2
12 of the License, or (at your option) any later version.
14 EdiTeX is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with EdiTeX; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 For details, see the EdiTeX World-Wide-Web page,
24 http://helm.cs.unibo.it/editex, or send a mail to
25 <luca.padovani@cs.unibo.it>
29 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
30 xmlns:tml="http://helm.cs.unibo.it/2002/TML"
31 xmlns:m="http://www.w3.org/1998/Math/MathML"
34 <xsl:output method="text" indent="yes"/>
36 <xsl:param name="id" select="/.."/>
38 <xsl:template match="/">
41 <xsl:apply-templates select="descendant::*[@id=$id]"/>
44 <xsl:apply-templates select="*"/>
49 <xsl:template match="tml:tex">
50 <xsl:apply-templates select="*"/>
53 <xsl:template match="tml:math">
55 <xsl:when test="@display='1'">$$<xsl:apply-templates select="*"/>$$</xsl:when>
56 <xsl:otherwise>$<xsl:apply-templates select="*"/>$</xsl:otherwise>
60 <xsl:template match="tml:i">
62 <xsl:when test="@name">\<xsl:value-of select="@name"/>
63 <xsl:if test="parent::tml:g and following-sibling::tml:i"><xsl:value-of select="' '"/></xsl:if>
65 <xsl:when test="string-length(@val)=1"><xsl:value-of select="@val"/></xsl:when>
66 <xsl:otherwise>{\it <xsl:value-of select="@val"/>}</xsl:otherwise>
70 <xsl:template match="tml:n">
72 <xsl:when test="@name">\<xsl:value-of select="@name"/>
73 <xsl:if test="parent::tml:g and following-sibling::tml:i"><xsl:value-of select="' '"/></xsl:if>
75 <xsl:when test="string-length(@val)=1"><xsl:value-of select="@val"/></xsl:when>
76 <xsl:otherwise>{\rm <xsl:value-of select="@val"/>}</xsl:otherwise>
80 <xsl:template match="tml:o">
82 <xsl:when test="@name">\<xsl:value-of select="@name"/>
83 <xsl:if test="parent::tml:g and following-sibling::tml:i"><xsl:value-of select="' '"/></xsl:if>
85 <xsl:when test="string-length(@val)=1"><xsl:value-of select="@val"/></xsl:when>
86 <xsl:otherwise><xsl:value-of select="@val"/></xsl:otherwise>
90 <xsl:template match="tml:sb">
92 <xsl:when test="@under='1'">
93 <xsl:apply-templates select="*[1]"/>__<xsl:apply-templates select="*[2]"/>
96 <xsl:apply-templates select="*[1]"/>_<xsl:apply-templates select="*[2]"/>
101 <xsl:template match="tml:sp">
103 <xsl:when test="@over='1'">
104 <xsl:apply-templates select="*[1]"/>^^<xsl:apply-templates select="*[2]"/>
107 <xsl:apply-templates select="*[1]"/>^<xsl:apply-templates select="*[2]"/>
112 <xsl:template match="tml:g[@id]">{<xsl:apply-templates select="*"/>}</xsl:template>
114 <xsl:template match="tml:g[count(*)>1]">{<xsl:apply-templates select="*"/>}</xsl:template>
116 <xsl:template match="tml:g">
117 <xsl:apply-templates select="*"/>
120 <xsl:template match="tml:row">
121 <xsl:apply-templates select="cell"/>\cr </xsl:template>
123 <xsl:template match="tml:cell">
124 <xsl:apply-templates select="*"/>
125 <xsl:if test="position() < last()">&</xsl:if>
128 <!--/// CONTROL SEQUENCES ///-->
130 <xsl:template match="tml:c[*[1][self::tml:g[@left-open='1']]]">
131 <xsl:apply-templates select="*[1]"/>\<xsl:value-of select="@name"/>
132 <xsl:if test="*[2][self::tml:i]"><xsl:value-of select="' '"/></xsl:if>
133 <xsl:apply-templates select="*[position()>1]"/>
136 <xsl:template match="tml:c">\<xsl:value-of select="@name"/>
137 <xsl:if test="*[1][self::tml:i]"><xsl:value-of select="' '"/></xsl:if>
138 <xsl:apply-templates select="*"/>