--- /dev/null
+<?xml version="1.0"?>
+
+<xsl:stylesheet
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:tml="http://helm.cs.unibo.it/2002/TML"
+ xmlns:m="http://www.w3.org/1998/Math/MathML"
+ version="1.0">
+
+ <xsl:output method="text" indent="yes"/>
+
+ <xsl:param name="id" select="/.."/>
+
+ <xsl:template match="/">
+ <xsl:choose>
+ <xsl:when test="$id">
+ <xsl:apply-templates select="descendant::*[@id=$id]"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="*"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template match="tml:tex">
+ <xsl:apply-templates select="*"/>
+ </xsl:template>
+
+ <xsl:template match="tml:math">
+ <xsl:choose>
+ <xsl:when test="@display='1'">$$<xsl:apply-templates select="*"/>$$</xsl:when>
+ <xsl:otherwise>$<xsl:apply-templates select="*"/>$</xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template match="tml:i">
+ <xsl:choose>
+ <xsl:when test="@name">\<xsl:value-of select="@name"/><xsl:value-of select="' '"/></xsl:when>
+ <xsl:when test="string-length(@val)=1"><xsl:value-of select="@val"/></xsl:when>
+ <xsl:otherwise>{\it <xsl:value-of select="@val"/>}</xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template match="tml:n">
+ <xsl:choose>
+ <xsl:when test="@name">\<xsl:value-of select="@name"/><xsl:value-of select="' '"/></xsl:when>
+ <xsl:when test="string-length(@val)=1"><xsl:value-of select="@val"/></xsl:when>
+ <xsl:otherwise>{\rm <xsl:value-of select="@val"/>}</xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template match="tml:o">
+ <xsl:choose>
+ <xsl:when test="@name">\<xsl:value-of select="@name"/><xsl:value-of select="' '"/></xsl:when>
+ <xsl:when test="string-length(@val)=1"><xsl:value-of select="@val"/></xsl:when>
+ <xsl:otherwise><xsl:value-of select="@val"/></xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template match="tml:sb">
+ <xsl:choose>
+ <xsl:when test="@under='1'">
+ <xsl:apply-templates select="*[1]"/>__<xsl:apply-templates select="*[2]"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="*[1]"/>_<xsl:apply-templates select="*[2]"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template match="tml:sp">
+ <xsl:choose>
+ <xsl:when test="@over='1'">
+ <xsl:apply-templates select="*[1]"/>^^<xsl:apply-templates select="*[2]"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="*[1]"/>^<xsl:apply-templates select="*[2]"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template match="tml:g[@id]">{<xsl:apply-templates select="*"/>}</xsl:template>
+
+ <xsl:template match="tml:g">
+ <xsl:apply-templates select="*"/>
+ </xsl:template>
+
+ <xsl:template match="tml:row">
+ <xsl:apply-templates select="cell"/>\cr </xsl:template>
+
+ <xsl:template match="tml:cell">
+ <xsl:apply-templates select="*"/>
+ <xsl:if test="position() < last()">&</xsl:if>
+ </xsl:template>
+
+<!--/// CONTROL SEQUENCES ///-->
+
+ <xsl:template match="tml:c[*[1][self::tml:g[@left-open='1']]]">
+ <xsl:apply-templates select="*[1]"/>\<xsl:value-of select="@name"/>
+ <xsl:if test="*[2][self::tml:i]"><xsl:value-of select="' '"/></xsl:if>
+ <xsl:apply-templates select="*[position()>1]"/>
+ </xsl:template>
+
+ <xsl:template match="tml:c">\<xsl:value-of select="@name"/>
+ <xsl:if test="*[1][self::tml:i]"><xsl:value-of select="' '"/></xsl:if>
+ <xsl:apply-templates select="*"/>
+ </xsl:template>
+
+</xsl:stylesheet>
+