<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">

  <xsl:template><xsl:value-of/></xsl:template>

  <xsl:template match="*"><SPAN STYLE="color:green"><xsl:attribute name="TITLE"><xsl:node-name/></xsl:attribute><xsl:apply-templates/></SPAN></xsl:template>

  <xsl:template match="/">
    <!--<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">-->
    <html>
      <head>
        <title><xsl:value-of select="artikel/kopf/titel"/></title>
        <STYLE>

          BODY        { margin:0px; background-color: #FFFFFF; width: 30em;
                        font-family: Verdana, Arial, Helvetica, sans-serif; font-size: small; }
          HR          { color: #cococo; text-align: left; margin-top: 1em; }
          P           { margin-top: .5em; margin-bottom: .25em; font-size: x-small; }
          H1          { text-align: left; font-size: medium; margin-top: .1em; margin-bottom: .1em; }
          H2          { text-align: left; font-size: small; margin-top: 3em; margin-bottom: .2em; }
          H3          { text-align: left; font-size: x-small; margin-top: 1.5em; margin-bottom: .1em; }
          .fn         { text-align: left; font-size: xx-small; margin-top: .5em; }
          .ebene1     { text-align: left; font-size: x-small; margin-top: .5em; }
          .ebene2     { text-align: left; font-size: x-small; margin-top: .25em; }
          .zitat      { text-align: left; font-size: x-small; margin-top: .25em; }
          .znachweis  { text-align: left; font-size: xx-small; }
          .bildunters { text-align: left; font-size: xx-small; font-style:italic; }
          .bib        { text-align: left; font-size: x-small; margin-top: .5em; }
          .inhalt     { text-align: left; font-size: x-small; margin-top: .25em; margin-bottom: 1.5em; }
          .loc        { color: blue; text-decoration: underline; }
          .email      { color: black; font-style: italic; }

          a:link      { color:red; text-decoration:none; }
          a:visited   { color:red; text-decoration:none; }
          a:hover     { color:blue; text-decoration:underline; }
          a:active    { color:blue; text-decoration:underline; }

        </STYLE>
      </head>
      <body>
        <table border="0" cellpadding="5" cellspacing="0" width="600">
        <tr>
        <td width="50"></td>
        <td width="550" valign="top">
        <xsl:for-each select="artikel/kopf">
          <br clear="ALL"/>
          <p><xsl:for-each select="autoren/autor"><xsl:value-of select="nachname"/>/</xsl:for-each></p>
          <h1><xsl:value-of select="titel"/></h1>
          <p>abgedruckt in "Muttersprache", 2/1998</p><br/>
        </xsl:for-each>

        <h3 class="inhalt">Inhalt</h3>
        <dl class="inhalt">
          <xsl:apply-templates select="artikel/textkoerper/ebene1">
            <xsl:template match="ebene1|ebene2|ebene3">
                <dt><xsl:eval>sectionNum(this)</xsl:eval>
                  <a><xsl:attribute name="href">#<xsl:choose>
                      <xsl:when test="@id"><xsl:value-of select="@id"/></xsl:when>
                      <xsl:otherwise>AEN<xsl:eval>uniqueID(this)</xsl:eval></xsl:otherwise>
                    </xsl:choose></xsl:attribute>
                    <xsl:value-of select="ueberschrift"/>
                  </a>
                </dt>
                <xsl:if test="ebene2|ebene3">
                  <dd><dl><xsl:apply-templates select="ebene2|ebene3"/></dl></dd>
                </xsl:if>
            </xsl:template>
          </xsl:apply-templates>
        </dl>

        <h3 class="inhalt">Anhang</h3>
        <dl class="inhalt">
          <xsl:apply-templates select="artikel/anhang/*">
            <xsl:template match="inform-ebene1|ebene1">
                <dt><xsl:eval>sectionNum(this)</xsl:eval>
                  <a><xsl:attribute name="href">#<xsl:choose>
                      <xsl:when test="@id"><xsl:value-of select="@id"/></xsl:when>
                      <xsl:otherwise>AEN<xsl:eval>uniqueID(this)</xsl:eval></xsl:otherwise>
                    </xsl:choose></xsl:attribute>
                    <xsl:value-of select="ueberschrift"/>
                  </a>
                </dt>
                <xsl:if test="ebene2">
                  <dd><dl><xsl:apply-templates select="ebene2"/></dl></dd>
                </xsl:if>
            </xsl:template>
            <xsl:template match="ebene2">
                <dt><xsl:eval>sectionNum(this)</xsl:eval>
                  <a><xsl:attribute name="href">#<xsl:choose>
                      <xsl:when test="@id"><xsl:value-of select="@id"/></xsl:when>
                      <xsl:otherwise>AEN<xsl:eval>uniqueID(this)</xsl:eval></xsl:otherwise>
                    </xsl:choose></xsl:attribute>
                    <xsl:value-of select="ueberschrift"/>
                  </a>
                </dt>
            </xsl:template>
            <xsl:template match="inform-ebene1">
                <dt><xsl:eval>sectionNum(this)</xsl:eval>
                  <a><xsl:attribute name="href">#<xsl:choose>
                      <xsl:when test="@id"><xsl:value-of select="@id"/></xsl:when>
                      <xsl:otherwise>AEN<xsl:eval>uniqueID(this)</xsl:eval></xsl:otherwise>
                    </xsl:choose></xsl:attribute>
                    <xsl:value-of select="ueberschrift"/>
                  </a> (Non-Normative)
                </dt>
            </xsl:template>
          </xsl:apply-templates>
        </dl>

        <xsl:apply-templates select="artikel/textkoerper"/>

        <hr width="25%"/>
        <h3>Anmerkungen</h3>
        <xsl:apply-templates select="artikel/textkoerper//fn">
          <xsl:template match="fn">
            <p class="fn">Anmerkung <xsl:eval>fnNumU1(this)</xsl:eval>: 
              <a><xsl:attribute name="name">FN<xsl:eval>fnNumU2(this)</xsl:eval></xsl:attribute>
                <xsl:value-of select="fntext"/>
              </a>
            </p>
          </xsl:template>
        </xsl:apply-templates>

        <xsl:apply-templates select="artikel/anhang"/>

        <h3>Kontakt zu den Autoren</h3>
        <p><xsl:apply-templates select="artikel/kopf/autoren/autor"/></p>
         
        <h3>Versionshinweise</h3>
        <p><xsl:for-each select="artikel/kopf/versionen/revision">
          Ver. <xsl:value-of select="revnummer"/>, <xsl:value-of select="revdatum"/><br/>
          <xsl:value-of select="revhinweis"/><br/><br/></xsl:for-each>
        </p>

        <p>http://www.mediensprache.net/de/publishing/publizieren/xml/</p>
      </td></tr>
      </table>
      </body>
    </html>
  </xsl:template>
  
  <xsl:template match="loc">
    <a class="loc"><xsl:attribute name="href"><xsl:value-of select="@href"/></xsl:attribute><xsl:value-of/></a>
  </xsl:template>

  <xsl:template match="bild">
    <IMG><xsl:attribute name="src"><xsl:value-of select="datei"/></xsl:attribute></IMG>
    <p class="bildunters">Abb. <xsl:eval>imgNum()</xsl:eval>: <xsl:value-of select="bildunterschrift"/></p>
  </xsl:template>

  <xsl:template match="autor">
    <span class="autor">
      <xsl:value-of select="vorname"/> <xsl:value-of select="nachname"/><br/>
      <span class="email"><xsl:value-of select="email"/></span><br/>
      <xsl:if test="homepage"><span class="email"><xsl:value-of select="homepage"/></span><br/></xsl:if>
      <br/>
    </span>
  </xsl:template>

  <xsl:template match="status | abstract | textkoerper | anhang"><xsl:apply-templates/></xsl:template>
  
  <xsl:template match="ebene1">
    <div class="ebene1">
      <h2><xsl:eval>sectionNum(this)</xsl:eval>
        <a><xsl:attribute name="name"><xsl:choose>
            <xsl:when test="@id"><xsl:value-of select="@id"/></xsl:when>
            <xsl:otherwise>AEN<xsl:eval>uniqueID(this)</xsl:eval></xsl:otherwise>
          </xsl:choose></xsl:attribute>
          <xsl:value-of select="ueberschrift"/>
        </a>
      </h2>
      <xsl:apply-templates/>
    </div>
  </xsl:template>
  
  <xsl:template match="ebene2">
    <div class="ebene2">
      <h3><xsl:eval>sectionNum(this)</xsl:eval>
        <a><xsl:attribute name="name"><xsl:choose>
            <xsl:when test="@id"><xsl:value-of select="@id"/></xsl:when>
            <xsl:otherwise>AEN<xsl:eval>uniqueID(this)</xsl:eval></xsl:otherwise>
          </xsl:choose></xsl:attribute>
          <xsl:value-of select="ueberschrift"/>
        </a>
      </h3>
      <xsl:apply-templates/>
    </div>
  </xsl:template>
  
  <xsl:template match="ebene3">
    <div class="ebene3">
      <h4><xsl:eval>sectionNum(this)</xsl:eval>
        <a><xsl:attribute name="name"><xsl:choose>
            <xsl:when test="@id"><xsl:value-of select="@id"/></xsl:when>
            <xsl:otherwise>AEN<xsl:eval>uniqueID(this)</xsl:eval></xsl:otherwise>
          </xsl:choose></xsl:attribute>
          <xsl:value-of select="ueberschrift"/>
        </a>
      </h4>
      <xsl:apply-templates/>
    </div>
  </xsl:template>
  
  <xsl:template match="ebene4">
    <div class="ebene4">
      <h5><xsl:eval>sectionNum(this)</xsl:eval>
        <a><xsl:attribute name="name"><xsl:choose>
            <xsl:when test="@id"><xsl:value-of select="@id"/></xsl:when>
            <xsl:otherwise>AEN<xsl:eval>uniqueID(this)</xsl:eval></xsl:otherwise>
          </xsl:choose></xsl:attribute>
          <xsl:value-of select="ueberschrift"/>
        </a>
      </h5>
      <xsl:apply-templates/>
    </div>
  </xsl:template>
  
  <xsl:template match="ebene5">
    <div class="ebene5">
      <h6><xsl:eval>sectionNum(this)</xsl:eval>
        <a><xsl:attribute name="name"><xsl:choose>
            <xsl:when test="@id"><xsl:value-of select="@id"/></xsl:when>
            <xsl:otherwise>AEN<xsl:eval>uniqueID(this)</xsl:eval></xsl:otherwise>
          </xsl:choose></xsl:attribute>
          <xsl:value-of select="ueberschrift"/>
        </a>
      </h6>
      <xsl:apply-templates/>
    </div>
  </xsl:template>
  
  <xsl:template match="inform-ebene1">
    <div class="inform-ebene1">
      <h2><xsl:eval>sectionNum(this)</xsl:eval>
        <a><xsl:attribute name="name"><xsl:choose>
            <xsl:when test="@id"><xsl:value-of select="@id"/></xsl:when>
            <xsl:otherwise>AEN<xsl:eval>uniqueID(this)</xsl:eval></xsl:otherwise>
          </xsl:choose></xsl:attribute>
          <xsl:value-of select="ueberschrift"/> (Non-Normative)
        </a>
      </h2>
      <xsl:apply-templates/>
    </div>
  </xsl:template>
  
  <xsl:template match="ueberschrift"/>
    
  <xsl:template match="abs">
    <p><b>[<xsl:eval>paraNum(this)</xsl:eval>]</b>
       <xsl:apply-templates/></p>
    </xsl:template>

  <xsl:template match="quote">"<xsl:apply-templates/>"</xsl:template>
  <xsl:template match="code"><code><xsl:apply-templates/></code></xsl:template>
  <xsl:template match="term"><i><xsl:apply-templates/></i></xsl:template>
  <xsl:template match="kursiv"><i><xsl:apply-templates/></i></xsl:template>
  <xsl:template match="eg"><pre><xsl:apply-templates/></pre></xsl:template>
  <xsl:template match="eg[@role='error']"><pre style="color:red"><xsl:apply-templates/></pre></xsl:template>
  
  <xsl:template match="fn">
    <span class="ebene1">
      <a><xsl:attribute name="href">#FN<xsl:eval>fnNum(this)</xsl:eval></xsl:attribute>[Anmerkung]</a>
    </span>
  </xsl:template>

  <xsl:template match="bibref">
    <a><xsl:attribute name="href">#<xsl:value-of select="@ref"/></xsl:attribute>[<xsl:value-of select="id(@ref)/@key"/>]</a>
  </xsl:template>
  
  <!-- BUGBUG  sectionNum adds the trailing ".", in this case a ":" is more appropriate -->
  <xsl:template match="specref">
    <a><xsl:attribute name="href">#<xsl:value-of select="@ref"/></xsl:attribute>
      <xsl:for-each select="id(@ref)">
        <b>Section <xsl:eval>sectionNum(this)</xsl:eval></b>
        <b><xsl:value-of select="ueberschrift"/></b></xsl:for-each></a>
  </xsl:template>

  <xsl:template match="termdef">
    <a><xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute></a>
    <xsl:apply-templates/></xsl:template>

  <xsl:template match="termref">
    <a><xsl:attribute name="href">#<xsl:value-of select="@def"/></xsl:attribute><xsl:apply-templates/></a></xsl:template>

  <!-- BUGBUG  strip off "issue-" from the id to turn it into the name -->
  <xsl:template match="issue">
    <div class="issue">
      <blockquote>
        <xsl:apply-templates>
          <xsl:template match="p[0]">
            <b><a><xsl:attribute name="name"><xsl:value-of select="../@id"/></xsl:attribute>
              Issue (<xsl:value-of select="../@id"/>):</a></b>
            <xsl:apply-templates/>
          </xsl:template>
        </xsl:apply-templates>
      </blockquote>
    </div>
  </xsl:template>

  <xsl:template match="zitat">
    <div class="zitat">
      <blockquote>
        <xsl:value-of select="zkoerper"/>
        <xsl:if test="znachweis"><p class="znachweis">(<xsl:value-of select="znachweis"/>)</p></xsl:if>
      </blockquote>
    </div>
  </xsl:template>

  <xsl:template match="zitatnum">
    <div class="zitat">
      <blockquote>
        <ol>
          <xsl:for-each select="znr">
            <li><xsl:apply-templates/></li>
          </xsl:for-each>
        </ol>
        <xsl:if test="cnsource"><p class="znachweis">(<xsl:value-of select="znrnachweis"/>)</p></xsl:if>
      </blockquote>
    </div>
  </xsl:template>

  <xsl:template match="note">
    <div class="note">
      <blockquote>
        <xsl:apply-templates>
          <xsl:template match="p[0]">
            <b>NOTE:</b>
            <xsl:apply-templates/>
          </xsl:template>
        </xsl:apply-templates>
      </blockquote>
    </div>
  </xsl:template>

  <xsl:template match="olist">
    <ol>
      <xsl:for-each select="item">
        <li><xsl:apply-templates/></li>
      </xsl:for-each>
    </ol>
  </xsl:template>

  <xsl:template match="ulist">
    <ul>
      <xsl:for-each select="item">
        <li><xsl:apply-templates/></li>
      </xsl:for-each>
    </ul>
  </xsl:template>

  <xsl:template match="slist">
    <ul class="slist">
      <xsl:for-each select="sitem">
        <li><xsl:apply-templates/></li>
      </xsl:for-each>
    </ul>
  </xsl:template>
  
  <xsl:template match="definitionen">
    <dl>
      <xsl:for-each select="def">
        <dt><xsl:apply-templates select="defbegriff"/></dt>
        <dd><xsl:apply-templates select="defdeutung"/></dd>
      </xsl:for-each>
    </dl>
  </xsl:template>
  <xsl:template match="defbegriff | defdeutung"><xsl:apply-templates/></xsl:template>

  <xsl:template match="bibliografie">
    <xsl:for-each select="bib">
      <p class="bib"><xsl:apply-templates/></p>
    </xsl:for-each>
  </xsl:template>

  <xsl:template match="scrap">
    <div class="scrap">
      <h4><xsl:value-of select="ueberschrift"/></h4>
      <hr/>
      <table border="0" width="100%">
        <xsl:for-each select="prod">
          <tr>
            <th align="LEFT" valign="TOP" width="5%"><a><xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute>
            [<xsl:eval>prodNum()</xsl:eval>]</a></th>
            <td align="LEFT" valign="TOP" width="20%"><xsl:apply-templates select="lhs"/></td>
            <td align="LEFT" valign="TOP" width="5%">::=</td>
            <td align="LEFT" valign="TOP" width="60%" colspan="2"><xsl:apply-templates select="rhs[0]"/></td>
          </tr>
          <xsl:for-each select="rhs[index()$gt$0]">
            <tr>
              <td width="5%"></td>
              <td width="20%"></td>
              <td width="5%"></td>
              <td align="LEFT" valign="TOP" width="60%" colspan="2"><xsl:apply-templates select="."/></td>
            </tr>
          </xsl:for-each>
        </xsl:for-each>
      </table>
      <hr/>
    </div>
  </xsl:template>

  <xsl:template match="lhs | rhs"><xsl:apply-templates/></xsl:template>

  <xsl:template match="xnt">
    <a><xsl:attribute name="href"><xsl:value-of select="@href"/></xsl:attribute><i><xsl:apply-templates/></i></a></xsl:template>

  <xsl:template match="prod//xnt">
    <a><xsl:attribute name="href"><xsl:value-of select="@href"/></xsl:attribute><xsl:apply-templates/></a></xsl:template>

  <xsl:template match="nt">
    <a><xsl:attribute name="href">#<xsl:value-of select="@def"/></xsl:attribute><i><xsl:apply-templates/></i></a></xsl:template>

  <xsl:template match="prod//nt">
    <a><xsl:attribute name="href">#<xsl:value-of select="@def"/></xsl:attribute><xsl:apply-templates/></a></xsl:template>

  <xsl:script><![CDATA[
    function sectionNum(e) {
      if (e)
      {
        if (e.parentNode.nodeName == "anhang")
          return formatIndex(absoluteChildNumber(e), "A") + ".";
        else
          return sectionNum(e.selectSingleNode("ancestor(inform-ebene1|ebene1|ebene2|ebene3|ebene4|ebene5)")) +
            formatIndex(childNumber(e), "1") + ".";
      }
      else
      {
        return "";
      }
    }
    
    var prodCount = 1;
    function prodNum() {
      return formatIndex(prodCount++, "1");
    }

    var paraCount = 1;
    function paraNum() {
      return formatIndex(paraCount++, "1");
    }

    var fnCount = 1;
    function fnNum() {
      return formatIndex(fnCount++, "1");
    }

    var fnCountU1 = 1;
    function fnNumU1() {
      return formatIndex(fnCountU1++, "1");
    }

    var fnCountU2 = 1;
    function fnNumU2() {
      return formatIndex(fnCountU2++, "1");
    }

    var imgCount = 1;
    function imgNum() {
      return formatIndex(imgCount++, "1");
    }

  ]]></xsl:script>

</xsl:stylesheet>
