<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
  xmlns:xs ="http://www.w3.org/2001/XMLSchema"
  xmlns:xhtml="http://www.w3.org/1999/xhtml"
  xmlns:pre="http://www.vishia.de/2006/XhtmlPre"
>
  <!-- ******************************************************************************************* -->
  <!-- ******************************************************************************************* -->
  <!-- ******************************************************************************************* -->
  <!-- presentation of the content of a class. The calling may be ransomed from generated DocuCtrl.xsl via
    GenDocuCtrl2Xsl.xsd -->

  <xsl:template name="umlClassContent">
  <xsl:param name="title" />
  <xsl:param name="methods">all</xsl:param>
  <xsl:param name="attributes">all</xsl:param>
    <xsl:variable name="anchor">class_<xsl:value-of select="@name"/></xsl:variable>

    <xsl:choose><xsl:when test="string-length($title)>0">

      <pre:chapter id="{$anchor}"><pre:title><xsl:value-of select="$title" /></pre:title>
        <xhtml:body style="UmlClassContent" >
          <xhtml:p class="umlElement"><xsl:text>Class </xsl:text><xhtml:b><xsl:value-of select="@name"
            /></xhtml:b><xsl:text> definiert in (?@package?)(?@class?)</xsl:text></xhtml:p>
          <xsl:call-template name="umlClassContent-i"><xsl:with-param name="attributes" select="$attributes"
            /><xsl:with-param name="methods" select="$methods" /></xsl:call-template>
        </xhtml:body>
      </pre:chapter>

    </xsl:when><xsl:otherwise>

      <xhtml:body style="UmlClassContent" >
        <xhtml:p class="umlTitle" id="{$anchor}"><xsl:text>Class (?@name?) im Package
          (?@package?)(?@class?)</xsl:text></xhtml:p>
        <xsl:call-template name="umlClassContent-i"><xsl:with-param name="attributes" select="$attributes"
          /><xsl:with-param name="methods" select="$methods" /></xsl:call-template>
      </xhtml:body>

    </xsl:otherwise></xsl:choose>

  </xsl:template>




  <!-- inner call of the content of a class. -->
  <xsl:template name="umlClassContent-i">
  <xsl:param name="methods">all</xsl:param>
  <xsl:param name="attributes">all</xsl:param>

    <xhtml:div expandWikistyle="true" class="umlDescription"><xsl:value-of
      select="tag[@name='documentation']"/></xhtml:div>

    <xhtml:div Backref="{@name}" />

    <xsl:if test="count(Attribute)>0">
      <xsl:choose><xsl:when test="$attributes='bytes'">
        <xhtml:p class="caption_P">Attribute:</xhtml:p>
        <xsl:call-template name="umlClassBytes"/>
        <xsl:call-template name="umlClassAttributesDetail">
          <!-- TODO choose sorted in adress order or name, with or without byte position -->
        </xsl:call-template>
      </xsl:when><xsl:when test="$attributes='all'">
          <xhtml:p class="caption_P">Attribute:</xhtml:p>
          <xsl:call-template name="umlClassAttributesDetail"/>
      </xsl:when><xsl:otherwise>
        <xsl:if test="count(Attribute/tag[@name='documentation'])>0">
          <xhtml:p class="title">Attribute:</xhtml:p>
          <xsl:call-template name="umlClassAttributesDetail"/>
        </xsl:if>
      </xsl:otherwise></xsl:choose>
    </xsl:if>

    <xsl:if test="boolean(Association/@name)">
      <!-- a nameless association is the second end of a directed association. -->
      <xhtml:p class="caption_p">Assoziationen:</xhtml:p>
      <xsl:call-template name="umlClassAssociationsDetail"/>
    </xsl:if>

    <xsl:if test="count(Operation)>0">
      <xsl:if test="$methods!='no'">
        <xhtml:p class="caption_p">Methoden:</xhtml:p>
        <xsl:if test="true() or count(Operation/tag[@name='documentation'])>0">
          <xsl:call-template name="umlClassMethodsDetail"/>
        </xsl:if>
      </xsl:if>
    </xsl:if>

    <xsl:for-each select="Enumeration">
      <xsl:if test="true()">
        <xhtml:p class="caption_p"><xsl:text>Enumeration (?@name?)</xsl:text></xhtml:p>
        <xsl:if test="true()">
          <xsl:call-template name="umlClassEnumerationDetail"/>
        </xsl:if>
      </xsl:if>
    </xsl:for-each>
  
  </xsl:template>



<!-- presentation of the attributes of a class in a definition list. Called from umlClassContent -->
<xsl:template name="umlClassAttributesDetail">
  <xhtml:dl>
    <xsl:for-each select="Attribute"> <!-- [count(tag[@name='documentation'])>0]" >           -->
    <xsl:sort select="@name" />
      <xsl:variable name="typeLabel"><xsl:text>#class_</xsl:text><xsl:call-template name="getTypeIdent"
        /></xsl:variable>
      <!-- Label built from Class.method(paramtype,paramtype) -->
      <xhtml:dt class="umlElement">
        <xhtml:b><xsl:value-of select="@name" /></xhtml:b><xsl:text> : </xsl:text><xhtml:a
          href="{$typeLabel}"><xsl:value-of select="@typeName"/></xhtml:a><xsl:text>(?if
          count(tag[@name='multiplicity'])>0?)[(?!tag[@name='multiplicity']?)](?/if?)</xsl:text>
      </xhtml:dt>
      <xhtml:dd expandWikistyle="true" class="umlDescription">
        <xsl:value-of select="tag[@name='documentation']" />
      </xhtml:dd>
    </xsl:for-each>
  </xhtml:dl>
</xsl:template>




<xsl:template name="getTypeIdent">
  <xsl:variable name="typeWithoutPointer">
    <xsl:choose><xsl:when test="contains(@typeName,' const*')">
      <xsl:value-of select="substring-before(@typeName,' const*')" />
    </xsl:when><xsl:when test="contains(@typeName,'*')">
      <xsl:value-of select="substring-before(@typeName,'*')" />
    </xsl:when><xsl:otherwise>
      <xsl:value-of select="@typeName" />
    </xsl:otherwise></xsl:choose>
  </xsl:variable>
  <xsl:variable name="typeWithoutModifier">
    <xsl:choose><xsl:when test="starts-with($typeWithoutPointer,'const ')">
      <xsl:value-of select="substring-after($typeWithoutPointer,'const ')" />
    </xsl:when><xsl:otherwise>
      <xsl:value-of select="$typeWithoutPointer" />
    </xsl:otherwise></xsl:choose>
  </xsl:variable>
    <xsl:choose><xsl:when test="substring($typeWithoutModifier,string-length($typeWithoutModifier)-1)='_t'">
      <xsl:value-of select="substring($typeWithoutModifier,1, string-length($typeWithoutModifier)-2)" />
    </xsl:when><xsl:otherwise>
      <xsl:value-of select="$typeWithoutModifier" />
    </xsl:otherwise></xsl:choose>
</xsl:template>






<!-- presentation of the associations of a class in a definition list. Called from umlClassContent -->
<xsl:template name="umlClassAssociationsDetail">
  <xhtml:dl>
    <xsl:for-each select="Association" >          <!-- select="Operation[@visibility='public']" -->
      <xsl:sort select="@name" />
      <!-- Label built from Class.method(paramtype,paramtype) -->
      <xhtml:dt class="umlElement">
        <xsl:text>(?@name?) : (?@classType?)(?if
          count(tag[@name='multiplicity'])>0?)[(?!tag[@name='multiplicity']?)](?/if?) </xsl:text>
      </xhtml:dt>
      <xhtml:dd expandWikistyle="true" class="umlDescription">
        <xsl:value-of select="tag[@name='documentation']" />
      </xhtml:dd>
    </xsl:for-each>
  </xhtml:dl>
</xsl:template>










<!-- presentation of the methods of a class in a definition list. Called from umlClassContent -->
<xsl:template name="umlClassMethodsDetail">
  <xhtml:dl>
    <xsl:for-each select="Operation[true() or count(tag[@name='documentation'])>0 and
      not(starts-with(tag[@name='documentation'],'#'))]" >          <!-- select="Operation[@visibility='public']" -->
      <xsl:sort select="@name" />
      <!-- Label built from Class.method(paramtype,paramtype) -->
      <xsl:variable name="LABEL"><xsl:value-of select="../@name"/>.<xsl:value-of select="@name"/>(<xsl:text/>
        <xsl:for-each select="Parameter[@kind!='return']" >
          <xsl:value-of select="@name"/><xsl:text>,</xsl:text>
        </xsl:for-each>)<xsl:text/>
      </xsl:variable>

      <xhtml:dt class="umlElement">
        <xhtml:b><xsl:value-of select="@name"/></xhtml:b><xsl:text> (</xsl:text>
          <xsl:for-each select="Parameter[@kind!='return']">
            <xsl:value-of select="@name"/><xsl:text>, </xsl:text>
          </xsl:for-each>
        <xsl:text>) : </xsl:text>
        <xsl:for-each select="Parameter[@kind='return']" >
          <xsl:variable name="typeLabel"><xsl:text>#class_</xsl:text><xsl:call-template name="getTypeIdent"
            /></xsl:variable>
          <xhtml:a href="{$typeLabel}"><xsl:value-of select="@typeName" /></xhtml:a>
        </xsl:for-each>
      </xhtml:dt>
      <xhtml:dd class="umlDescription">
        <xhtml:div expandWikistyle="true" class="umlDescription"><xsl:value-of select="tag[@name='documentation']"
          /></xhtml:div>
        <!-- xsl:if test="count(Parameter[@kind!='return'])>0" -->
        <xsl:if test="count(Parameter[@kind!='return' and @name!='ythis'])>0" ><!-- ythis is used in C-like methods -->
          <xhtml:ul>
            <xsl:for-each select="Parameter[@kind!='return' and @name!='ythis']" ><!-- ythis is used in C-like methods
              -->
              <xsl:variable name="typeLabel"><xsl:text>class_</xsl:text><xsl:call-template name="getTypeIdent"
                /></xsl:variable>
              <xhtml:li>
                <xhtml:div expandWikistyle="true" class='umlDescription'><xsl:text>'''(?@name?)''' :
                  [[(?$typeLabel?)|(?@typeName?)]] - </xsl:text>
                  <xsl:value-of select="tag[@name='documentation']" />
                </xhtml:div>
              </xhtml:li>
            </xsl:for-each>
          </xhtml:ul>
        </xsl:if>
      </xhtml:dd>
    </xsl:for-each>
  </xhtml:dl>
</xsl:template>






<!-- ******************************************************************************************* -->
<!-- ******************************************************************************************* -->
<!-- ******************************************************************************************* -->
<!-- presentation of the attributes of a class in a byte image. Called from umlClassContent -->
<xsl:template name="umlClassBytes">
  <xsl:for-each select="Attribute[1]">
    <!-- call for the first attribute, the rest is called recursively with using the axes following-sibling -->
    <xsl:call-template name="attributes-bytes"/>
  </xsl:for-each>
</xsl:template>



<xsl:template name="attributes-bytes">
<!-- writes one attribute block, and recursively via following bytes, the next blocks -->
<xsl:param name="sumsizeof" select="'0'" /><!--summe of sizeof from the calls before for this line -->
<xsl:param name="prevsizeof" select="'0'" /><!--bytes in the previous block, lines above. -->
  <xhtml:pre class="bytes">
    <xsl:call-template name="attributes-bytes-top" >
      <xsl:with-param name="prevsizeof" select="$prevsizeof" />
    </xsl:call-template>
  </xhtml:pre>
  <xhtml:pre class="bytes">
    <xsl:call-template name="attributes-bytes-name" />
  </xhtml:pre>
  <xsl:call-template name="following-bytes">
    <xsl:with-param name="sumsizeof" select="'0'" /><!-- because it is a new line -->
    <xsl:with-param name="prevsizeof" select="$prevsizeof" />
  </xsl:call-template>

</xsl:template>




<xsl:template name="attributes-bytes-top">
<!-- writes top line for one attribute, recursive called, inside a xhtml:pre -->
<xsl:param name="sumsizeof" select="'0'" /><!--summe of sizeof from the calls before for this line -->
<xsl:param name="prevsizeof" select="'0'" /><!--bytes in the previous block, lines above. -->
  <xsl:variable name="sizeof"><xsl:call-template name="sizeof" /></xsl:variable>
  <xsl:variable name="sumNew" select="number($sumsizeof + $sizeof)" />
    <xsl:choose>
      <xsl:when test="$sizeof=1"><xsl:text>+-------</xsl:text></xsl:when>
      <xsl:when test="$sizeof=2"><xsl:text>+-------'-------</xsl:text></xsl:when>
      <xsl:when test="$sizeof=4"><xsl:text>+-------'-------'-------'-------</xsl:text></xsl:when>
      <xsl:otherwise><xsl:text>+---------------------------------------------------------------</xsl:text></xsl:otherwis
        >
    </xsl:choose>
    <xsl:choose><xsl:when test="$sumNew &lt; 8 and boolean(following-sibling::Attribute[1])">
      <!-- recursively call for next word only for this line with max 8 bytes-->
      <xsl:for-each select="following-sibling::Attribute[1]">
        <xsl:call-template name="attributes-bytes-top" >
          <xsl:with-param name="sumsizeof" select="$sumNew" />
          <xsl:with-param name="prevsizeof" select="$prevsizeof" />
        </xsl:call-template>
      </xsl:for-each>
    </xsl:when><xsl:otherwise>
      <!-- after last calling: -->
      <xsl:call-template name="attributes-bytes-bottom">
        <xsl:with-param name="sizeof" select="number($prevsizeof - $sumNew)" />
      </xsl:call-template>
      <!-- xsl:text>(test: prev=(?$prevsizeof?) sum=(?$sumNew?))</xsl:text -->
    </xsl:otherwise></xsl:choose>
</xsl:template>





<xsl:template name="sizeof">
<!-- returns the sizeof depends of the type -->
  <xsl:choose>
    <xsl:when test="contains(@typeName,'*')>0">4</xsl:when>
    <xsl:when test="@typeName='char'">1</xsl:when>
    <xsl:when test="@typeName='uint8'">1</xsl:when>
    <xsl:when test="@typeName='int8'">1</xsl:when>
    <xsl:when test="@typeName='int16'">2</xsl:when>
    <xsl:when test="@typeName='uint16'">2</xsl:when>
    <xsl:when test="@typeName='int32'">4</xsl:when>
    <xsl:when test="@typeName='uint32'">4</xsl:when>
    <xsl:when test="@typeName='float'">4</xsl:when>
    <xsl:when test="tag[@name='sizeof']"><xsl:value-of select="tag[@name='sizeof']/@value" /></xsl:when>
    <xsl:otherwise>8</xsl:otherwise><!-- may be a embedded structure -->
  </xsl:choose>
</xsl:template>


<xsl:template name="following-bytes">
<!-- writes a following block if some more attributes exists, or writes the bottom line. -->
<xsl:param name="sumsizeof" select="'0'" /><!--summe of sizeof from the calls before for this line -->
<xsl:param name="prevsizeof" select="'64'" /><!--bytes in the previous block, lines above. -->
  <xsl:variable name="sizeof"><xsl:call-template name="sizeof" /></xsl:variable>
  <xsl:variable name="sumNew" select="number($sumsizeof + $sizeof)" />
    <xsl:choose><xsl:when test="$sumNew &lt; 8 and boolean(following-sibling::Attribute[1])">
      <!-- recursively call for next word in this line with max 8 bytes-->
      <xsl:for-each select="following-sibling::Attribute[1]">
        <xsl:call-template name="following-bytes" >
          <xsl:with-param name="sumsizeof" select="$sumNew" />
        </xsl:call-template>
      </xsl:for-each>
    </xsl:when><xsl:when test="boolean(following-sibling::Attribute[1])">
      <!-- recursively call for next block -->
      <xsl:for-each select="following-sibling::Attribute[1]">
        <xsl:call-template name="attributes-bytes" >
          <xsl:with-param name="prevsizeof" select="$sumNew" /><!-- the size of the block above, it should be 8 -->
          <xsl:with-param name="sumsizeof" select="'0'" /><!-- because it starts in a new line -->
        </xsl:call-template>
      </xsl:for-each>
    </xsl:when><xsl:otherwise>
      <!-- after last calling: -->
      <!-- NOTE: the $sumNew is calculated from the recursively call for next word in the last line. -->
      <xhtml:pre class="bytes">
        <xsl:call-template name="attributes-bytes-bottom">
          <xsl:with-param name="sizeof" select="number($sumNew)" /><!-- number of bytes above -->
        </xsl:call-template>
      </xhtml:pre>
    </xsl:otherwise></xsl:choose>
</xsl:template>




<xsl:template name="attributes-bytes-bottom">
<xsl:param name="sizeof" select="'0'" />
    <xsl:value-of select="substring('+-------------------------------------------------------------------------',1,8 *
      $sizeof)"/>
    <xsl:text>+</xsl:text>
</xsl:template>




<xsl:template name="attributes-bytes-name">
<xsl:param name="sumsizeof" select="'0'" />
<!-- writes the name of the next attributes formatted -->
  <!-- NOTE: be carefull by editing the next line, inside there are preserved spaces, code 0xA0 -->
  <xsl:variable name="spaces"><xsl:text>                                                   </xsl:text></xsl:variable>
  <xsl:variable name="sizeof"><xsl:call-template name="sizeof" /></xsl:variable>
  <xsl:variable name="sumNew" select="number($sumsizeof + $sizeof)" />
  <xsl:variable name="value">
    <xsl:text>(?@name?)</xsl:text>
  </xsl:variable>
  <xsl:variable name="nrofSpace" select="8*number($sizeof) - string-length($value)-1" />
  <xsl:variable name="nrofSpace1" select="floor($nrofSpace div 2)" />
  <xsl:variable name="nrofSpace2" select="$nrofSpace - $nrofSpace1" />
    <xsl:choose><xsl:when test="count(tag[@name='multiplicity'])>0">
      <xsl:text>|(?!substring($spaces,1,$nrofSpace1 -4)?)... (?!substring($value,1, 8*$sizeof -1)?)
        ...(?!substring($spaces,1,$nrofSpace2 -4)?)</xsl:text>
    </xsl:when><xsl:otherwise>
    <xsl:text>|(?!substring($spaces,1,$nrofSpace1)?)(?!substring(@name,1, 8*$sizeof
      -1)?)(?!substring($spaces,1,$nrofSpace2)?)</xsl:text>
    </xsl:otherwise></xsl:choose>
    <!-- xsl:value-of select="$nrofSpace" / -->
    <!-- xsl:value-of select="substring($spaces,1,$nrofSpace)" / -->

    <!-- recursively call for next word -->
    <xsl:choose>
      <xsl:when test="$sumNew &lt; 8 and boolean(following-sibling::Attribute[1])">
        <xsl:for-each select="following-sibling::Attribute[1]">
          <xsl:call-template name="attributes-bytes-name">
            <xsl:with-param name="sumsizeof" select="$sumNew" />
          </xsl:call-template>
        </xsl:for-each>
      </xsl:when><xsl:otherwise>
        <!-- after last calling: -->
        <xsl:text>|</xsl:text>
      </xsl:otherwise>
    </xsl:choose>
</xsl:template>









<!-- presentation of the attributes of a class in a definition list. Called from umlClassContent -->
<xsl:template name="umlClassEnumerationDetail">
  <xhtml:dl>
    <xsl:for-each select="EnumerationLiteral"> <!-- [count(tag[@name='documentation'])>0]" >           -->
      <xhtml:dt class="umlElement">
        <xhtml:b><xsl:value-of select="@name" /></xhtml:b><xsl:text> :
          (?!tag[@name='hexvalue']?)(?!tag[@name='intvalue']?)(?!tag[@name='symbolvalue']?)(?!tag[@name='expressionvalue
          ]?)</xsl:text>
      </xhtml:dt>
      <xhtml:dd expandWikistyle="true" class="umlDescription">
        <xsl:value-of select="tag[@name='documentation']" />
      </xhtml:dd>
    </xsl:for-each>
  </xhtml:dl>
</xsl:template>






<!-- ******************************************************************************************* -->
<!-- ******************************************************************************************* -->
<!-- ******************************************************************************************* -->






  <!-- Darstellung des Inhaltes eines Package -->
  <xsl:template name="pkgContent">
    <xhtml:body style="UmlClassContent" >
      <xsl:variable name="LABEL">#PKG.<xsl:value-of select="@name"/></xsl:variable>
      <xhtml:anchor label="{$LABEL}"/>
      <xhtml:p style="standard"><xhtml:u>Package: <xsl:value-of select="@name"/></xhtml:u></xhtml:p>
      <xhtml:body expandWikistyle="true"><xsl:value-of select="tag[@name='documentation']"/></xhtml:body>
    </xhtml:body>

  </xsl:template>




  <!-- Darstellung des Inhaltes einer Klasse -->
  <xsl:template name="classContentShort"><!-- version bis 2006-10-23, neu ist umlClass -->
      <xhtml:body style="UmlClassContent" >
        <xsl:variable name="LABEL">class_<xsl:value-of select="@name"/></xsl:variable>
        <xhtml:anchor label="{$LABEL}"/>
        <xhtml:p>.</xhtml:p>
        <xhtml:p style="standard"><xhtml:u>Class: <xsl:value-of select="@name"/></xhtml:u> im Package:<xsl:value-of
          select="@package"/><xsl:value-of select="@class"/></xhtml:p>
        <xhtml:div expandWikistyle="true" style='standard'><xsl:value-of
          select="tag[@name='documentation']"/></xhtml:div>
        <xsl:if test="count(Operation/tag[@name='documentation'])>0">
          <xhtml:table border="1" width="100%"><xhtml:tr><xhtml:th
            width="30%">Methode</xhtml:th><xhtml:th>Beschreibung</xhtml:th></xhtml:tr>
            <xsl:for-each select="Operation[count(tag[@name='documentation'])>0 and
              not(starts-with(tag[@name='documentation'],'#'))]" >          <!--
              select="Operation[@visibility='public']" -->
              <xsl:sort select="@name" />
              <!-- Label built from Class.method(paramtype,paramtype) -->
              <xsl:variable name="LABEL"><xsl:value-of select="../@name"/>.<xsl:value-of select="@name"/>(<xsl:text/>
                <xsl:for-each select="Parameter[@kind!='return']" >
                  <xsl:value-of select="@typeName"/><xsl:text>,</xsl:text>
                </xsl:for-each>)<xsl:text/>
              </xsl:variable>

              <xhtml:tr>
                <xhtml:td><xhtml:internref label="{$LABEL}"><xsl:value-of select="@name"/></xhtml:internref></xhtml:td>
                <xhtml:td>
                  <xhtml:div expandWikistyle="true" style='standard'><xsl:value-of select="tag[@name='documentation']"
                    /></xhtml:div>
                  <!-- xsl:if test="count(Parameter[@kind!='return'])>0" -->
                  <xhtml:ul>
                    <xsl:for-each select="Parameter[@kind!='return']" >
                      <xhtml:li>
                        <xhtml:div expandWikistyle="true" style='standard'><xsl:text>''</xsl:text><xsl:value-of
                          select="@name"/><xsl:text>'': </xsl:text>
                          <xsl:value-of select="tag[@name='documentation']" />
                        </xhtml:div>
                      </xhtml:li>
                    </xsl:for-each>
                  </xhtml:ul>
                </xhtml:td>
              </xhtml:tr>
            </xsl:for-each>
          </xhtml:table>
        </xsl:if>
        <xsl:if test="count(Attribute/tag[@name='documentation'])>0">
          <xhtml:p>Attribute:</xhtml:p>
          <xhtml:table border="1" width="100%"><xhtml:tr><xhtml:th
            width="30%">Attribute</xhtml:th><xhtml:th>Beschreibung</xhtml:th></xhtml:tr>
            <xsl:for-each select="Attribute[count(tag[@name='documentation'])>0]" >          <!--
              select="Operation[@visibility='public']" -->
              <xsl:sort select="@name" />
              <!-- Label built from Class.method(paramtype,paramtype) -->
              <xhtml:tr>
                <xhtml:td><xsl:value-of select="@name"/></xhtml:td>
                <xhtml:td>
                  <xhtml:div expandWikistyle="true" style='standard'><xsl:value-of select="tag[@name='documentation']"
                    /></xhtml:div>
                </xhtml:td>
              </xhtml:tr>
            </xsl:for-each>
          </xhtml:table>
        </xsl:if>
        <!-- xsl:if test="count(Association/tag[@name='documentation'])>0" -->
        <xsl:if test="count(xxxAssociation)>0">
          <xhtml:p>Assoziationen:</xhtml:p>
          <xhtml:table border="1" width="100%"><xhtml:tr><xhtml:th
            width="30%">Assoziation</xhtml:th><xhtml:th>Zielklasse</xhtml:th><xhtml:th>Beschreibung</xhtml:th></xhtml:tr
            
            <!-- xsl:for-each select="Association[count(tag[@name='documentation'])>0]" -->
            <xsl:for-each select="Association" >
              <xsl:sort select="@name" />
              <xsl:variable name="LABEL">class_<xsl:value-of select="@classType"/></xsl:variable>
              <xhtml:tr>
                <xhtml:td><xsl:value-of select="@name"/></xhtml:td>
                <xhtml:td><xhtml:internref label="{$LABEL}"><xsl:value-of
                  select="@classType"/></xhtml:internref></xhtml:td>
                <xhtml:td>
                  <xhtml:div expandWikistyle="true" style='standard'><xsl:value-of select="tag[@name='documentation']"
                    /></xhtml:div>
                </xhtml:td>
              </xhtml:tr>
            </xsl:for-each>
          </xhtml:table>
        </xsl:if>
      </xhtml:body>

  </xsl:template>




  <xsl:template name="typeWithReference">
  <!-- writes the typename with or without a internref -->
    <xsl:if test="count(@typeName)>0 and @typePackage!='-?-'">
      <xsl:variable name="HREF">#CLASS.<xsl:value-of select="@typeName"/></xsl:variable>
      <xhtml:internref label="{$HREF}"><xsl:value-of select="@typeName"/></xhtml:internref>
    </xsl:if>
    <xsl:if test="count(@typeName)>0 and @typePackage='-?-'">
      <xsl:value-of select="@typeName"/>
    </xsl:if>
  </xsl:template>


  <!-- ******************************************************************************************* -->
  <!-- ******************************************************************************************* -->
  <!-- ******************************************************************************************* -->


  <xsl:template name="umlStatechart">
    <xhtml:body>
      <xhtml:p style='standard'>Statechart of <xsl:value-of select="@name"/></xhtml:p>
      <xsl:variable name="LabelPrefix"><xsl:value-of select="@package"/><xsl:value-of select="@class"/><xsl:value-of
        select="@name"/></xsl:variable>
      <xsl:for-each select="StateMachine">
        <xhtml:div expandWikistyle="true" style='standard'><xsl:value-of
          select="tag[@name='documentation']"/></xhtml:div>
        <xhtml:ul>
          <xsl:for-each select="State">
            <xhtml:li><xsl:call-template name="umlStateDescriptionAndTransitions"><xsl:with-param name="LabelPrefix"
              select="$LabelPrefix"/></xsl:call-template></xhtml:li>
          </xsl:for-each>
        </xhtml:ul>

        <xsl:for-each select=".//State">
          <xsl:if test="count(State)>0">
            <xsl:variable name="LabelSubstates"><xsl:value-of
              select="$LabelPrefix"/><xsl:text>_SUB_</xsl:text><xsl:value-of select="@name"/></xsl:variable>
            <xhtml:anchor label="{$LabelSubstates}"/>
            <xhtml:p style="standard"><xhtml:u>
              <xsl:choose><xsl:when test="@isConcurrent='true'"><xsl:text>Parallele Zweige</xsl:text></xsl:when>
              <xsl:otherwise><xsl:text>Substates</xsl:text></xsl:otherwise></xsl:choose>
              <xsl:text> von </xsl:text><xsl:value-of select="@name"/></xhtml:u></xhtml:p>
            <xhtml:ul>
              <xsl:for-each select="State">
                <xhtml:li><xsl:call-template name="umlStateDescriptionAndTransitions"><xsl:with-param name="LabelPrefix"
                  select="$LabelPrefix"/></xsl:call-template></xhtml:li>
              </xsl:for-each>
            </xhtml:ul>
          </xsl:if>
        </xsl:for-each>
      </xsl:for-each>
    </xhtml:body>
  </xsl:template>



  <xsl:template name="umlStateDescriptionAndTransitions">
  <xsl:param name="LabelPrefix"/>
    <xsl:variable name="Name">
      <xsl:choose><xsl:when test="string-length(@name)>0"><xsl:value-of select="@name"/></xsl:when>
      <xsl:otherwise><xsl:value-of select="@xmi.id"/></xsl:otherwise></xsl:choose>
    </xsl:variable>
    <xsl:variable name="LabelState"><xsl:value-of select="$LabelPrefix"/><xsl:text>_</xsl:text><xsl:value-of
      select="$Name"/></xsl:variable>
    <xhtml:anchor label="{$LabelState}"/>
    <xhtml:p style='standard'><xhtml:u>
      <xsl:choose><xsl:when test="@kind='branch'"><xsl:text>branch </xsl:text></xsl:when>
      <xsl:otherwise><xsl:text>State: </xsl:text></xsl:otherwise></xsl:choose>
      <xsl:value-of select="$Name"/>
      </xhtml:u>
      <xsl:if test="count(State)>0">
        <!-- hyperlink to the documentation of the substates -->
        <xsl:variable name="LabelSubstates"><xsl:value-of select="$LabelPrefix"/>_SUB_<xsl:value-of
          select="@name"/></xsl:variable>
        <xhtml:internref label="{$LabelSubstates}">
          <xsl:choose><xsl:when test="@isConcurrent='true'"><xsl:text> (mit parallelen Zweigen)</xsl:text></xsl:when>
          <xsl:otherwise><xsl:text> (mit Substates)</xsl:text></xsl:otherwise></xsl:choose>
        </xhtml:internref>
      </xsl:if>
    </xhtml:p>
    <xhtml:div expandWikistyle="true" style='standard'><xsl:value-of select="tag[@name='documentation']"/></xhtml:div>
    <xsl:if test="count(Transition)>0">
      <xhtml:ul>
        <xsl:for-each select="Transition[count(tag[@name='documentation'])>0]">
          <xsl:variable name="TargetName">
            <xsl:choose><xsl:when test="string-length(@targetState-name)>0"><xsl:value-of
              select="@targetState-name"/></xsl:when>
            <xsl:otherwise><xsl:value-of select="@targetState-id"/></xsl:otherwise></xsl:choose>
          </xsl:variable>
          <xhtml:li><xhtml:p style='standard_li'>
            <xsl:variable name="LabelState"><xsl:value-of select="$LabelPrefix"/><xsl:text>_</xsl:text><xsl:value-of
              select="$TargetName"/></xsl:variable>
            <xhtml:internref label="{$LabelState}">
              <xhtml:u>==&gt; <xsl:value-of select="$TargetName"/><xsl:text>: </xsl:text>
              </xhtml:u>
            </xhtml:internref>
            <xsl:value-of select="tag[@name='displayName']"/></xhtml:p>
              <xhtml:div expandWikistyle="true"  style='standard_li'><xsl:value-of
                select="tag[@name='documentation']"/></xhtml:div>
          </xhtml:li>
        </xsl:for-each>
      </xhtml:ul>
    </xsl:if>
  </xsl:template>




  <!-- ******************************************************************************************* -->
  <!-- ******************************************************************************************* -->
  <!-- ******************************************************************************************* -->

  <xsl:template name="umlComment">
  <xsl:param name="param1"></xsl:param>
    <xhtml:body expandWikistyle="true"  style='standard'>
      <xsl:choose><xsl:when test="contains(.,'###')">
        <xsl:value-of select="substring-after(.,'###')"/>
      </xsl:when><xsl:otherwise>
        <xsl:value-of select="."/>
      </xsl:otherwise></xsl:choose>
    </xhtml:body>
  </xsl:template>




  <!-- ******************************************************************************************* -->
  <!-- ******************************************************************************************* -->
  <!-- ******************************************************************************************* -->

  <xsl:template name="umlSQDdescription">
  <xsl:param name="param1"></xsl:param>
    <xhtml:body expandWikistyle="true"  style='standard'><xsl:value-of
      select="tag[@name='documentation']"/></xhtml:body>
  </xsl:template>





  <!-- ******************************************************************************************* -->
  <!-- ******************************************************************************************* -->
  <!-- ******************************************************************************************* -->

  <xsl:template name="errorNotFound">
  <xsl:param name="param1"></xsl:param>
    <xhtml:body><xhtml:p class="errormsg">ERROR: not found ---&gt;<xsl:value-of
      select="$param1"/>&lt;---</xhtml:p></xhtml:body>
  </xsl:template>









</xsl:stylesheet>