4 This file is part of EdiTeX, an editor of mathematical
5 expressions based on TeX syntax.
7 Copyright (C) 2002-2003 Luca Padovani <lpadovan@cs.unibo.it>,
8 2003 Paolo Marinelli <pmarinel@cs.unibo.it>.
10 This library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU Lesser General Public
12 License as published by the Free Software Foundation; either
13 version 2.1 of the License, or (at your option) any later version.
15 This library is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
20 You should have received a copy of the GNU Lesser General Public
21 License along with this library; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 For more information, please visit the project's home page
25 http://helm.cs.unibo.it/editex/
26 or send an email to <lpadovan@cs.unibo.it>
30 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
31 xmlns:tml="http://helm.cs.unibo.it/2002/TML"
32 xmlns:m="http://www.w3.org/1998/Math/MathML"
35 <xsl:output method="text" indent="yes"/>
37 <xsl:param name="id" select="/.."/>
39 <xsl:template match="/">
42 <xsl:apply-templates select="descendant::*[@id=$id]"/>
45 <xsl:apply-templates select="*"/>
50 <xsl:template match="tml:tex">
51 <xsl:apply-templates select="*"/>
54 <xsl:template match="tml:math">
56 <xsl:when test="@display='1'">$$<xsl:apply-templates select="*"/>$$</xsl:when>
57 <xsl:otherwise>$<xsl:apply-templates select="*"/>$</xsl:otherwise>
61 <xsl:template match="tml:i">
63 <xsl:when test="@name">\<xsl:value-of select="@name"/>
64 <xsl:if test="parent::tml:g and following-sibling::tml:i"><xsl:value-of select="' '"/></xsl:if>
66 <xsl:when test="string-length(@val)=1"><xsl:value-of select="@val"/></xsl:when>
67 <xsl:otherwise>{\it <xsl:value-of select="@val"/>}</xsl:otherwise>
71 <xsl:template match="tml:n">
73 <xsl:when test="@name">\<xsl:value-of select="@name"/>
74 <xsl:if test="parent::tml:g and following-sibling::tml:i"><xsl:value-of select="' '"/></xsl:if>
76 <xsl:when test="string-length(@val)=1"><xsl:value-of select="@val"/></xsl:when>
77 <xsl:otherwise>{\rm <xsl:value-of select="@val"/>}</xsl:otherwise>
81 <xsl:template match="tml:o">
83 <xsl:when test="@name">\<xsl:value-of select="@name"/>
84 <xsl:if test="parent::tml:g and following-sibling::tml:i"><xsl:value-of select="' '"/></xsl:if>
86 <xsl:when test="string-length(@val)=1"><xsl:value-of select="@val"/></xsl:when>
87 <xsl:otherwise><xsl:value-of select="@val"/></xsl:otherwise>
91 <xsl:template match="tml:sb">
93 <xsl:when test="@under='1'">
94 <xsl:apply-templates select="*[1]"/>__<xsl:apply-templates select="*[2]"/>
97 <xsl:apply-templates select="*[1]"/>_<xsl:apply-templates select="*[2]"/>
102 <xsl:template match="tml:sp">
104 <xsl:when test="@over='1'">
105 <xsl:apply-templates select="*[1]"/>^^<xsl:apply-templates select="*[2]"/>
108 <xsl:apply-templates select="*[1]"/>^<xsl:apply-templates select="*[2]"/>
113 <xsl:template match="tml:g[@id]">{<xsl:apply-templates select="*"/>}</xsl:template>
115 <xsl:template match="tml:g[count(*)>1]">{<xsl:apply-templates select="*"/>}</xsl:template>
117 <xsl:template match="tml:g">
118 <xsl:apply-templates select="*"/>
121 <xsl:template match="tml:row">
122 <xsl:apply-templates select="cell"/>\cr </xsl:template>
124 <xsl:template match="tml:cell">
125 <xsl:apply-templates select="*"/>
126 <xsl:if test="position() < last()">&</xsl:if>
129 <!--/// CONTROL SEQUENCES ///-->
131 <xsl:template match="tml:c[*[1][self::tml:g[@left-open='1']]]">
132 <xsl:apply-templates select="*[1]"/>\<xsl:value-of select="@name"/>
133 <xsl:if test="*[2][self::tml:i]"><xsl:value-of select="' '"/></xsl:if>
134 <xsl:apply-templates select="*[position()>1]"/>
137 <xsl:template match="tml:c">\<xsl:value-of select="@name"/>
138 <xsl:if test="*[1][self::tml:i]"><xsl:value-of select="' '"/></xsl:if>
139 <xsl:apply-templates select="*"/>