<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE xsl:stylesheet
          [
          <!ENTITY cr "&#xD;"><!ENTITY lf "&#xA;"><!ENTITY sp "&#xA0;"><!ENTITY br "&lf;">
		  <!ENTITY IE "<xsl:comment xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>[if IE]&gt;&#xD;&#xA;&lt;![endif]</xsl:comment>">
		  <!ENTITY BR "<xsl:comment xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>[if IE]&gt;&lt;br/&gt;&lt;![endif]</xsl:comment>">
          <!ENTITY nl "<xsl:text xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>&cr;&lf;</xsl:text>">
          <!ENTITY el "&lt;{name()}&gt;-element">
          ]>
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:xhtml="http://www.w3.org/1999/xhtml"
                xmlns:xlink="http://www.w3.org/1999/xlink"
                xmlns:TeXML="http://www.unterstein.net/ML/TeXML"
                xmlns:ent="urn:entitags:entity-as-empty-element-tag"
                xmlns="http://www.w3.org/1999/xhtml"
                exclude-result-prefixes="xhtml TeXML xlink ent"
                >

<xsl:output indent="no"
            method="xml"
            encoding="utf-8"
            media-type="text/xml"
            doctype-public="-//W3C//DTD XHTML 1.1//EN"
            doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"
            omit-xml-declaration="no"
            />
<xsl:preserve-space elements="*" />
<xsl:strip-space elements="xhtml:tr"/>

<xsl:template name="XSLTproc">
    <xsl:text>%% XML v</xsl:text><xsl:value-of select="system-property('xsl:version')" /><xsl:text>&br;</xsl:text>&BR;
    <xsl:text>%% XSLTransformed by &br;</xsl:text>&BR;
    <xsl:text>%%   </xsl:text><xsl:value-of select="system-property('xsl:vendor')" /><xsl:call-template name="MSIEhack"><xsl:with-param name="MSIEcode" select="' [NOTE: problems w/ whitespace, linebreak, subset-entities transformation]'" /></xsl:call-template><xsl:text>&br;</xsl:text>&BR;
    <xsl:text>%%   </xsl:text><a href="{system-property('xsl:vendor-url')}"><xsl:value-of select="system-property('xsl:vendor-url')" /></a><xsl:text>&br;</xsl:text>&BR;
</xsl:template>

<xsl:variable name="MSIEproc" select="system-property('xsl:vendor')='Microsoft'" />
<xsl:template name="MSIEhack">
    <xsl:param name="MSIEcode" />
	<xsl:if test="$MSIEproc">
	<xsl:comment><xsl:text>[if IE]&gt;</xsl:text><xsl:value-of select="$MSIEcode" /><xsl:text>&lt;![endif]</xsl:text></xsl:comment>
	</xsl:if>
</xsl:template>

<!--  ================================================  -->
<!--  ================================================

<xsl:comment>[if IE]&gt;&#xD;&#xA;&lt;![endif]</xsl:comment>

<xsl:call-template name="MSIEhack">
<xsl:with-param name="MSIEcode" select="'&#xD;&#xA;'" />
</xsl:call-template>

      ================================================  -->
<!--  ================================================  -->

<xsl:template name="LFtoCRLF">
    <xsl:param name="str" />
    <xsl:choose>
        <xsl:when test="contains($str,'&#xA;')">
            <xsl:value-of select="substring-before($str,'&#xA;')" /><xsl:text>&#xD;&#xA;</xsl:text>
            <xsl:call-template name="LFtoCRLF">
                <xsl:with-param name="str" select="substring-after($str,'&#xA;')" />
            </xsl:call-template>
        </xsl:when>
        <xsl:otherwise>
            <xsl:value-of select="$str" />
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>

<xsl:template match="text()">
    <xsl:choose>
        <xsl:when test="$MSIEproc">
			<xsl:call-template name="LFtoCRLF">
				<xsl:with-param name="str" select="." />
			</xsl:call-template>
        </xsl:when>
        <xsl:otherwise>
            <xsl:value-of select="." />
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>

<!--  ================================================  -->
<!--  ================================================  -->

<xsl:template match="/">
    <html>
    <head><title><xsl:value-of select="//xhtml:title" /></title>
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <style type="text/css">
        <xsl:text>
            html {background: white none;}
            body {color: #000; padding: 10px;} 
		    div  {background: #f0f0f0 none; padding: 10px;}
            pre  {font: normal 9pt/13pt 'andale mono', 'bitstream vera sans mono', 'lucida console', 'lucida sans typewriter', 'ocr a extended', 'courier new', courier, monospace; margin-left: 10px;}
            b    {font-weight: normal; }
            .cmd {color: #900;}
            .env {color: #900;}
            .grp {color: #00f;}
            .act {background-color: #ff6;}
            .opt {color: #00f;}
            .arg {color: #00f;}
			.par {background-color: white;}
            .x   {background-color: #f5f5f5;}
            .TeX {color: #999;}
            .ent1 {background-color: #efe;}  /* dtd-parsed/doc-intern light-green */
            .ent2 {background-color: #fee;}  /* xsl-extern/xsl-import light-red   */
            .ent3 {background-color: #eef;}  /* xsl-intern light-blue  */
            .ref {color: #f00;}
            .tab {color: #906;}
			.outer {
				margin: 0px;
				padding: 0px;
				border-width: 1px;
				border-style: solid;
				border-color: gray white white gray;
			}
			.inner {
				margin: 0px;
				padding: 4px;
				border-width: 1px;
				border-style: solid;
				border-color: white gray gray white;
                font: normal 9pt/13pt &quot;courier new&quot;, monospace;
			}   /* head/foot */
        </xsl:text>
    </style>
    </head>
    <body>
        <xsl:apply-templates />
    </body>
    </html>
</xsl:template>

<xsl:template match="TeXML:TeXML|TeXML">
	<div>
	<div class="outer">
    <pre class="inner" title="static &lt;xsl:text&gt; (not document)">
        <xsl:text>%%&br;</xsl:text>&BR;
            <xsl:call-template name="XSLTproc" />
		<xsl:text>%%&br;</xsl:text>&BR;
		<xsl:text>%% TeXML dtd/fpi: &quot;-//StUs//DTD TeXML//EN&quot;&br;</xsl:text>&BR;
		<xsl:text>%% TeXML dtd/uri: &quot;</xsl:text><a href="http://www.unterstein.net/ML/TeXML.dtd">http://www.unterstein.net/ML/TeXML.dtd</a><xsl:text>&quot;&br;</xsl:text>&BR;
		<xsl:text>%% TeXML    xslt: &quot;</xsl:text><a href="http://www.unterstein.net/ML/TeXML-HTpre.xsl">http://www.unterstein.net/ML/TeXML-HTpre.xsl</a><xsl:text>&quot;&br;</xsl:text>&BR;
		<xsl:text>%% TeXML   xmlns: &quot;http://www.unterstein.net/ML/TeXML&quot;&br;</xsl:text>&BR;
		<xsl:text>%%&br;</xsl:text>
	</pre>
	
    <pre class="inner" title="static &lt;xsl:text&gt; (not document)">
        <xsl:text>%%&br;</xsl:text>&BR;
		<xsl:text>%% XSLTransformed from &br;</xsl:text>&BR;
        <xsl:text>%%   </xsl:text><b class="cmd">&lt;cmd&gt;-element</b><xsl:text>&br;</xsl:text>&BR;
        <xsl:text>%%   </xsl:text><b class="env">&lt;env&gt;-element</b><xsl:text>&br;</xsl:text>&BR;
        <xsl:text>%%   </xsl:text><b class="grp">&lt;grp&gt;-element</b><xsl:text>&br;</xsl:text>&BR;
        <xsl:text>%%   </xsl:text><b class="opt">&lt;opt&gt;-element</b><xsl:text>&br;</xsl:text>&BR;
        <xsl:text>%%   </xsl:text><b class="arg">&lt;arg&gt;-element</b><xsl:text>&br;</xsl:text>&BR;
        <xsl:text>%%   </xsl:text><b class="act">&lt;act&gt;-element</b><xsl:text>&br;</xsl:text>&BR;
        <xsl:text>%%   </xsl:text><b class="TeX">&lt;TeX&gt;-element or &lt;?TeX?&gt; processing-instruction (both TeX internal code)</b><xsl:text>&br;</xsl:text>&BR;
        <xsl:text>%%   </xsl:text><b class="par">&lt;par&gt;-element (TeX-paragraph simulacrum)</b><xsl:text>&br;</xsl:text>&BR;
        <xsl:text>%%   </xsl:text><b class="x">&lt;x&gt;-element (TeXML all-purpose-wrapper w/o wrap-attribute)</b><xsl:text>&br;</xsl:text>&BR;
        <xsl:text>%%   </xsl:text><b class="ent1">&lt;ent:*&gt;-element (&quot;entitag&quot;, dtd-parsed or doc-intern)</b><xsl:text>&br;</xsl:text>&BR;
        <xsl:text>%%   </xsl:text><b class="ent2">&lt;ent:*&gt;-element (&quot;entitag&quot;, xsl-extern or xsl-import)</b><xsl:text>&br;</xsl:text>&BR;
        <xsl:text>%%   </xsl:text><b class="ent3">&lt;ent:*&gt;-element (&quot;entitag&quot;, xsl-intern)</b><xsl:text>&br;</xsl:text>&BR;
        <xsl:text>%%&br;</xsl:text>
	</pre>
	
    <pre class="inner" title="static &lt;xsl:text&gt; (not document)">
        <xsl:text>%%&br;</xsl:text>&BR;
        <xsl:text>%% &lt;TeXML&gt; \input&br;</xsl:text>&BR;
        <xsl:text>%%&br;</xsl:text>
    </pre>
	</div>
	</div>
	
    <pre xml:space="preserve">
        <xsl:apply-templates />
    </pre>
	
	<div>
	<div class="outer">
    <pre class="inner" title="static &lt;xsl:text&gt; (not document)">
        <xsl:text>%%&br;</xsl:text>&BR;
        <xsl:text>%% \endinput &lt;/TeXML&gt;&br;</xsl:text>&BR;
        <xsl:text>%%&br;</xsl:text>&BR;
    </pre>
	</div>
	</div>
</xsl:template>

<xsl:template match="xhtml:*" />
<xsl:template match="*[@type='xml'] | *[@role='xml'] | *[@TeXML:type='xml'] | *[@TeXML:role='xml']" priority="1" />

<!--  ================================================  -->
<!--  ================================================  -->

<xsl:template match="TeXML:TeX|TeX">
    <b class="TeX" title="&el;">
    <xsl:value-of select="." />
    </b>
</xsl:template>
<xsl:template match="processing-instruction('TeX')">
    <b class="TeX" title="&lt;?TeX?&gt;-instruction">
    <xsl:value-of select="." />
    </b>
</xsl:template> <!--  PI 2005-03-28  -->

<xsl:template match="TeXML:cmd|cmd">
    <b class="cmd" title="&el;">
    <xsl:text>\</xsl:text><xsl:value-of select="@name" />
                          <xsl:value-of select="@args" />
    </b>
    <xsl:apply-templates />
</xsl:template>
<xsl:template match="TeXML:cmd[not(child::node()) and not(@args) and following-sibling::node()[1][self::text()]]">
    <b class="cmd" title="&el;">
    <xsl:text>\</xsl:text><xsl:value-of select="@name" />
	<xsl:text> </xsl:text>
	</b>
</xsl:template> <!--  WS 2005-04-18 (empty) command+space (if) text  -->

<xsl:template match="TeXML:env|env">
    <xsl:variable name="name">
        <xsl:if test="not(@bg)"><xsl:text>{</xsl:text></xsl:if><xsl:value-of select="@bg" />
        <xsl:value-of select="@name" />
        <xsl:if test="not(@eg)"><xsl:text>}</xsl:text></xsl:if><xsl:value-of select="@eg" />
    </xsl:variable>
    <b class="env" title="&el;">
    <xsl:if test="not(@bc)"><xsl:text>\begin</xsl:text></xsl:if><xsl:value-of select="@bc" />
    <xsl:value-of select="$name" />
    <xsl:value-of select="@args" />
    </b>
    <xsl:apply-templates />
    <b class="env" title="&el;">
    <xsl:if test="not(@ec)"><xsl:text>\end</xsl:text></xsl:if><xsl:value-of select="@ec" />
    <xsl:value-of select="$name" />
    </b>
</xsl:template>

<!--  ================================================  -->
<!--  ================================================  -->

<xsl:template match="TeXML:opt|opt">
    <span title="&el;">
    <b class="opt">
        <xsl:if test="not(@bg)">
            <xsl:text>[</xsl:text>    <!--  default in TeXML.dtd  -->
        </xsl:if>
    <xsl:value-of select="@bg" />
    </b>
    <xsl:apply-templates />
    <b class="opt">
        <xsl:if test="not(@eg)">
            <xsl:text>]</xsl:text>    <!--  default in TeXML.dtd  -->
        </xsl:if>
    <xsl:value-of select="@eg" />
    </b>
    </span>
</xsl:template>

<xsl:template match="TeXML:arg|arg">
    <span title="&el;">
    <b class="arg">
        <xsl:if test="not(@bg)">
            <xsl:text>{</xsl:text>    <!--  default in TeXML.dtd  -->
        </xsl:if>
    <xsl:value-of select="@bg" />
    </b>
    <xsl:apply-templates />
    <b class="arg">
        <xsl:if test="not(@eg)">
            <xsl:text>}</xsl:text>    <!--  default in TeXML.dtd  -->
        </xsl:if>
    <xsl:value-of select="@eg" />
    </b>
    </span>
</xsl:template>

<xsl:template match="TeXML:grp|grp">
    <span title="&el;">
    <b class="grp">
        <xsl:if test="not(@bg)">
            <xsl:text>{</xsl:text>    <!--  default in TeXML.dtd  -->
        </xsl:if>
    <xsl:value-of select="@bg" />
    </b>
    <xsl:apply-templates />
    <b class="grp">
        <xsl:if test="not(@eg)">
            <xsl:text>}</xsl:text>    <!--  default in TeXML.dtd  -->
        </xsl:if>
    <xsl:value-of select="@eg" />
    </b>
    </span>
</xsl:template>

<!--  ================================================  -->
<!--  ================================================  -->

<xsl:template name="texnames">
    <xsl:param name="tn" />
    <xsl:choose>
        <xsl:when test="contains($tn,' ')">
            <xsl:text>\</xsl:text><xsl:value-of select="substring-before($tn,' ')" />
            <xsl:call-template name="texnames">
                <xsl:with-param name="tn" select="substring-after($tn,' ')" />
            </xsl:call-template>
        </xsl:when>
        <xsl:otherwise>
            <xsl:text>\</xsl:text><xsl:value-of select="$tn" />
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>

<xsl:template match="TeXML:grp[@name]">
    <span title="&el;">
    <b class="grp">
        <xsl:if test="not(@bg)">
            <xsl:text>{</xsl:text>    <!--  default in TeXML.dtd  -->
        </xsl:if>
    <xsl:value-of select="@bg" />
    <xsl:call-template name="texnames">
        <xsl:with-param name="tn" select="normalize-space(@name)" />
    </xsl:call-template>
    </b>
    <xsl:if test="child::node()[1][self::text()]"><xsl:text> </xsl:text></xsl:if> <!--  commands space contents  -->
    <xsl:apply-templates />
    <b class="grp">
        <xsl:if test="not(@eg)">
            <xsl:text>}</xsl:text>    <!--  default in TeXML.dtd  -->
        </xsl:if>
    <xsl:value-of select="@eg" />
    </b>
    </span>
</xsl:template>

<!--  ================================================  -->
<!--  ================================================  -->

<xsl:template match="TeXML:act|act">
    <b class="act" title="&el;"><xsl:value-of select="@on" /></b>
</xsl:template>

<xsl:template match="TeXML:par|par | TeXML:x|x">
    <span class="{local-name()}" title="&el;"><xsl:apply-templates /></span>
    &nl;&BR;
</xsl:template>

<xsl:template match="TeXML:x[@wrap]">
    <xsl:apply-templates /> <!-- just don't mark this -->
</xsl:template>

<!--  ================================================  -->
<!--  ================================================  -->
<!--                 Linking & Refering                 -->

<xsl:template name="ifidlabel">
    <xsl:if test="@id">
        <b class="ref"><xsl:text>\label{</xsl:text></b>
        <xsl:value-of select="@id" />
        <b class="ref"><xsl:text>}</xsl:text></b>
    </xsl:if>
</xsl:template>

<xsl:template name="ifidhyper">
    <xsl:if test="@id">
        <b class="ref"><xsl:text>\hypertarget{</xsl:text></b>
            <xsl:value-of select="@id" />
        <b class="ref"><xsl:text>}{</xsl:text></b>
            <xsl:apply-templates />
        <b class="ref"><xsl:text>}</xsl:text></b>
    </xsl:if>
</xsl:template>

<xsl:template name="xlinkhref">
    <xsl:if test="@xlink:href">
        <b class="ref"><xsl:text>{</xsl:text></b>
            <xsl:choose>
                <xsl:when test="starts-with(@xlink:href,'#')">
                    <xsl:value-of select="substring-after(@xlink:href,'#')" />
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="@xlink:href" />
                </xsl:otherwise>
            </xsl:choose>
        <b class="ref"><xsl:text>}</xsl:text></b>
    </xsl:if>
</xsl:template>

<!--  ================================================  -->
<!--  ================================================  -->

<xsl:template match="xhtml:a">
    <span title="&el;">
    <xsl:call-template name="ifidlabel" />
    <xsl:choose>
        <xsl:when test="starts-with(@href,'#')">
            <b class="ref"><xsl:text>\hyperlink{</xsl:text></b>
            <xsl:value-of select="substring-after(@href,'#')" />
        </xsl:when>
        <xsl:otherwise>
            <b class="ref"><xsl:text>\href{</xsl:text></b>
            <xsl:value-of select="@href" />
        </xsl:otherwise>
    </xsl:choose>
    <b class="ref"><xsl:text>}{</xsl:text></b>
        <xsl:apply-templates />
    <b class="ref"><xsl:text>}</xsl:text></b>
    </span>
</xsl:template>

<xsl:template match="xhtml:a[not(@href)]">
    <span title="&el;">
    <xsl:choose>
        <xsl:when test="*|text()">
            <xsl:call-template name="ifidhyper" />
        </xsl:when>
        <xsl:otherwise>
            <xsl:call-template name="ifidlabel" />
        </xsl:otherwise>
    </xsl:choose>
    </span>
</xsl:template>

<xsl:template match="xhtml:img">
    <span title="&el;">
    <b class="ref"><xsl:text>\hyperimg{</xsl:text></b>
        <xsl:value-of select="@src" />
    <b class="ref"><xsl:text>}</xsl:text></b>
    </span>
    <xsl:if test="@width">
        <xsl:text> % wd:</xsl:text><xsl:value-of select="@width" /><xsl:text>px</xsl:text>
    </xsl:if>
    <xsl:if test="@height">
        <xsl:text> % ht:</xsl:text><xsl:value-of select="@height" /><xsl:text>px</xsl:text>
    </xsl:if>
</xsl:template>

<xsl:template match="TeXML:cmd[@name='href'] | TeXML:cmd[@name='hyperlink'] | TeXML:cmd[@name='hyperimg']">
    <span title="xlink:*ed &el;">
    <b class="ref">
    <xsl:text>\</xsl:text><xsl:value-of select="@name" />
                          <xsl:value-of select="@args" />
    </b>
    <xsl:call-template name="xlinkhref" />
    <xsl:apply-templates />
    </span>
</xsl:template>
<!--  this template processes the commands \href \hyperlink \hyperimg
      i.e.
      e.g. <cmd name="href"
                xlink:type="simple"
                xlink:show="replace"
                xlink:actuate="onRequest"
                xlink:href="URI"><arg>anchor-text</arg></cmd>
      e.g. <cmd name="hyperimg"
                xlink:type="simple"
                xlink:show="embed"
                xlink:actuate="onLoad"
                xlink:href="SRC" />
      all <cmd> <env> <x> elements can be xlinks, but the attributes are ignored for TeX
  -->

<xsl:template match="TeXML:cmd[@name='label' and not(@args)] | TeXML:cmd[@name='hypertarget' and not(@args)]">
    <b class="ref"><xsl:text>\</xsl:text><xsl:value-of select="@name" />
    <xsl:text>{</xsl:text></b><xsl:value-of select="@id"   /><b class="ref"><xsl:text>}</xsl:text></b>
    <xsl:apply-templates />
</xsl:template>
<!--  this template processes the commands \hypertarget \label
      i.e.
      e.g. <cmd name="hypertarget"
                id="id"><arg>anchor-text</arg></cmd>
      e.g. <cmd name="label" id="id" />
      not: <cmd name="label" args="texmark" id="id" />
      all other <cmd> <env> <x> elements can have ids, but they are ignored for TeX
      beware: xml-id-conventions are much more restrictive than TeX-label-conventions
      beware: any args-attribute (a TeX-label) has precedence over an id-attribute
  -->
<xsl:template match="TeXML:cmd[@name='ref' and not(@args)] | TeXML:cmd[@name='pageref' and not(@args)]">
    <b class="ref"><xsl:text>\</xsl:text><xsl:value-of select="@name" />
    <xsl:text>{</xsl:text></b><xsl:value-of select="@to"   /><b class="ref"><xsl:text>}</xsl:text></b>
    <xsl:apply-templates />
</xsl:template>

<xsl:template match="TeXML:cmd[@name='hyperref' and not(@args)]">
    <b class="ref"><xsl:text>\</xsl:text><xsl:value-of select="@name" /></b>
    <xsl:if test="@to">
        <b class="ref"><xsl:text>[</xsl:text></b><xsl:value-of select="@to"   /><b class="ref"><xsl:text>]</xsl:text></b>
    </xsl:if>
    <xsl:apply-templates />
</xsl:template>

<xsl:template match="TeXML:ANY | xlink:*">
    <xsl:apply-templates />
</xsl:template>

<!--  ================================================  -->
<!--  ================================================  -->

<xsl:template match="TeXML:env[@name='tabular']">      <!--  xhtml:table ignored ! -->
    <xsl:variable name="name">
        <xsl:if test="not(@bg)"><xsl:text>{</xsl:text></xsl:if><xsl:value-of select="@bg" />
        <xsl:value-of select="@name" />
        <xsl:if test="not(@eg)"><xsl:text>}</xsl:text></xsl:if><xsl:value-of select="@eg" />
    </xsl:variable>
    <b class="tab">
    <xsl:if test="not(@bc)"><xsl:text>\begin</xsl:text></xsl:if><xsl:value-of select="@bc" />
    <xsl:value-of select="$name" />
    <xsl:value-of select="@args" />
    </b>
    <xsl:choose> <!--  to change xhtml-order thead|tfoot|tbody  -->
        <xsl:when test="child::xhtml:thead or child::xhtml:tbody or child::xhtml:tfoot">
            <xsl:apply-templates select="child::xhtml:thead" />
            <xsl:apply-templates select="child::xhtml:tbody" />
            <xsl:apply-templates select="child::xhtml:tfoot" />
        </xsl:when>
        <xsl:otherwise>
            <xsl:apply-templates />
        </xsl:otherwise>
    </xsl:choose>
    <b class="tab">
    <xsl:if test="not(@ec)"><xsl:text>\end</xsl:text></xsl:if><xsl:value-of select="@ec" />
    <xsl:value-of select="$name" />
    </b>
</xsl:template>

<xsl:template match="xhtml:thead | xhtml:tbody | xhtml:tfoot">
    <xsl:apply-templates />
</xsl:template>

<xsl:template match="xhtml:tr">
    <xsl:apply-templates />
    <b class="tab"><xsl:text> \\</xsl:text></b>
</xsl:template>

<xsl:template match="xhtml:td | xhtml:th">
    <xsl:if test="self::xhtml:th"><b class="tab"><xsl:text>\bfseries </xsl:text></b></xsl:if>
    <xsl:apply-templates />
    <xsl:if test="following-sibling::xhtml:td or following-sibling::xhtml:th">
        <b class="tab"><xsl:text> &amp; </xsl:text></b>
    </xsl:if>
</xsl:template>

<xsl:template match="xhtml:td[@colspan] | xhtml:th[@colspan]">
    <b class="tab"><xsl:text>\multicolumn{</xsl:text></b>
        <xsl:value-of select="@colspan" />
    <b class="tab"><xsl:text>}{</xsl:text></b>
    <xsl:choose>
        <xsl:when test="@align">
            <xsl:value-of select="substring(@align,1,1)" />
        </xsl:when>
        <xsl:otherwise>
            <xsl:text>c</xsl:text>
        </xsl:otherwise>
    </xsl:choose>
    <b class="tab"><xsl:text>}{</xsl:text></b>
    <xsl:if test="self::xhtml:th"><xsl:text>\bfseries </xsl:text></xsl:if>
    <xsl:apply-templates />
    <b class="tab"><xsl:text>}</xsl:text></b>
    <xsl:if test="following-sibling::xhtml:td or following-sibling::xhtml:th">
        <b class="tab"><xsl:text> &amp; </xsl:text></b>
    </xsl:if>
</xsl:template>


<!--  ================================================  -->
<!--  ================================================  -->
<!--  entitags.xml 2003-12-21                           -->


<xsl:template match="ent:*">
    <b class="ent2" title="&el;, xsl-extern">
    <xsl:variable name="TagName" select="local-name()" />
    <xsl:value-of select="document('entitags.xml')//ent:el[@tagname=$TagName]/@texcode" />
    </b>
</xsl:template>

<xsl:template match="ent:*[@texcode]"><b class="ent1" title="&el;, dtd-parsed/doc-intern"><xsl:value-of select="@texcode" /></b></xsl:template>


<!--  entitags.xml 2003-12-21                           -->
<!--  ================================================  -->
<!--  ================================================  -->


<!--  ================================================  -->
<!--  ================================================  -->

</xsl:stylesheet>

<!--  ================================================  -->
<!--  ================================================  -->
<!--                 TeXML-HTpre.xsl EOF                -->
