<?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"
>


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



<!-- presentation of the content of a class. The calling may be ransomed from generated DocuCtrl.xsl via
  GenDocuCtrl2Xsl.xsd -->
<xsl:template name="dataStruct">
<xsl:param name="className" select="'?'"/>
<xsl:param name="methods">all</xsl:param>
<xsl:param name="attributes">all</xsl:param>
  <xhtml:body>
    <xsl:variable name="LABEL"><xsl:text>class_(?$className?)</xsl:text></xsl:variable>
    <anchor label="{$LABEL}"/>
    <xhtml:p class="standard" id="{$LABEL}"><xhtml:u>struct <xsl:value-of select="$className"/></xhtml:u></xhtml:p>

    <xsl:for-each select="Cheader/class[@name=$className]/structDefinition/attribute[1]">
      <xsl:call-template name="attributes-bytes" />
    </xsl:for-each>
    <xhtml:p class="standard"><xsl:value-of
      select="Cheader/class[@name=$className]/structDefinition/description/brief"/><xsl:text>.</xsl:text></xhtml:p>
    <xsl:copy-of select="Cheader/class[@name=$className]/structDefinition/description/rest/xhtml:body/*"/>
    <xsl:call-template name="attributes-list"><xsl:with-param name="className" select="$className"/></xsl:call-template>
  </xhtml:body>
</xsl:template>


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



<!-- presentation of the content of a class. The calling may be ransomed from generated DocuCtrl.xsl via
  GenDocuCtrl2Xsl.xsd -->
<xsl:template name="headerClass">
<xsl:param name="className" select="'?'"/>
<xsl:param name="methods">all</xsl:param>
<xsl:param name="attributes">all</xsl:param>
  <!-- NOTE: use xsl:for-each select="Cheader/class[@name=$className]/..." in all parts of the description
       because the input of description may be dispersed in several headerfiles and thus dispersed in several input xml
         files.
   -->
    <xhtml:body>
      <xsl:variable name="LABEL">class_<xsl:value-of select="$className"/></xsl:variable>
      <anchor label="{$LABEL}"/>
      <xhtml:p class="class_title"><xhtml:u>Class: <xsl:value-of select="$className"/></xhtml:u></xhtml:p>
      <xhtml:p class="class_brief"><xsl:for-each
        select="Cheader/class[@name=$className]"><xsl:text>(?!structDefinition/description/brief?).</xsl:text></xsl:for-
        ach></xhtml:p>
      <xsl:for-each select="Cheader/class[@name=$className]">
        <xsl:apply-templates select="structDefinition/description/rest/xhtml:body/*">
          <xsl:with-param name="pStyle" select="'class_text'" />
          <xsl:with-param name="ulStyle" select="'class_ul'" />
          <xsl:with-param name="olStyle" select="'class_ol'" />
          <xsl:with-param name="dlStyle" select="'class_dl'" />
          <xsl:with-param name="tableStyle" select="'class_table'" />
        </xsl:apply-templates>
      </xsl:for-each>

      <xsl:if test="$attributes!='no'">
        <xsl:for-each select="Cheader/class[@name=$className]/structDefinition/attribute[1]">
          <xsl:call-template name="attributes-bytes" />
        </xsl:for-each>
        <xsl:call-template name="attributes-list"><xsl:with-param name="className"
          select="$className"/></xsl:call-template>
      </xsl:if>

      <xsl:if test="$methods!='no'">
        <xsl:call-template name="class-methods" />


        <xsl:if test="true() or count(Operation/tag[@name='documentation'])>0">
          <xhtml:table width="100%">
          <xhtml:tr><xhtml:th width="30%"></xhtml:th><xhtml:th>Methods - Overview</xhtml:th></xhtml:tr>
            <xsl:for-each
              select="Cheader/class[@name=$className]/methodDef[not(starts-with(name,'constructor'))]|defineDefinition"
              >
              <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="typedParameter|parameter" >
                  <xsl:value-of select="@name"/><xsl:text>,</xsl:text>
                </xsl:for-each>)<xsl:text/>
              </xsl:variable>

              <xhtml:tr>
                <xhtml:td class="code">
                  <xsl:call-template name="typeName" />
                  <xsl:if test="local-name()='defineDefinition'"><xsl:text>#define</xsl:text></xsl:if>
                </xhtml:td>
                <xhtml:td>
                  <xhtml:dl>
                    <xhtml:dt class="code">
                      <xsl:text> </xsl:text><b><xsl:value-of select="@name"/></b>
                      <xsl:text>(</xsl:text>
                        <xsl:for-each select="typedParameter|parameter" >
                          <xsl:call-template name="typeName" />
                          <xsl:text> </xsl:text><xsl:value-of select="@name"/>
                          <xsl:text>,</xsl:text>
                        </xsl:for-each>
                      <xsl:text>)</xsl:text>
                    </xhtml:dt>
                    <xhtml:dd><xsl:copy-of select="description/brief/xhtml:body/*" /></xhtml:dd>
                  </xhtml:dl>
                </xhtml:td>
              </xhtml:tr>
            </xsl:for-each>
          </xhtml:table>
        </xsl:if>
      </xsl:if>

      <xsl:if test="$methods!='no'">
        <xsl:if test="true() or count(Operation/tag[@name='documentation'])>0">
          <xhtml:dl>
            <xsl:for-each select="Cheader/class[@name=$className]/methodDef[not(starts-with(name,'constructor'))]" >
              <!-- 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="typedParameter[@kind!='return']" >
                  <xsl:value-of select="@name"/><xsl:text>,</xsl:text>
                </xsl:for-each>)<xsl:text/>
              </xsl:variable>

              <xhtml:dt class="code">
                <!-- internref label="{$LABEL}">xxx</internref -->
                  <xsl:value-of select="type/@name"/>
                  <xsl:text> </xsl:text><xhtml:b><xsl:value-of select="@name"/></xhtml:b>
                  <xsl:text>(</xsl:text>
                    <xsl:for-each select="typedParameter" >
                      <xsl:value-of select="@name"/><xsl:text>, </xsl:text>
                    </xsl:for-each>
                  <xsl:text>)</xsl:text>
                </xhtml:dt>
                <xhtml:dd>
                  <xsl:copy-of select="description/brief" />
                  <xsl:apply-templates select="description/rest/xhtml:body/*">
                    <xsl:with-param name="pStyle" select="'class_text'" />
                    <xsl:with-param name="ulStyle" select="'class_text_ul'" />
                    <xsl:with-param name="olStyle" select="'class_text_ol'" />
                    <xsl:with-param name="dlStyle" select="'class_text_dl'" />
                    <xsl:with-param name="tableStyle" select="'class_text_table'" />
                  </xsl:apply-templates>
                  <xhtml:ul>
                    <xsl:for-each select="description/paramDescription" >
                      <xhtml:li>
                        <xsl:value-of select="@name" /><xsl:text>: </xsl:text>
                        <xsl:copy-of select="brief" />
                        <xsl:apply-templates select="rest/xhtml:body/*">
                          <xsl:with-param name="pStyle" select="'class_text'" />
                          <xsl:with-param name="ulStyle" select="'class_text_ul'" />
                          <xsl:with-param name="olStyle" select="'class_text_ol'" />
                          <xsl:with-param name="dlStyle" select="'class_text_dl'" />
                          <xsl:with-param name="tableStyle" select="'class_text_table'" />
                        </xsl:apply-templates>
                      </xhtml:li>
                    </xsl:for-each>
                  </xhtml:ul>
                </xhtml:dd>
            </xsl:for-each>
          </xhtml:dl>
        </xsl:if>
      </xsl:if>

      <xsl:if test="count(structDefinition/attribute/description)>0">
        <xhtml:p class="inner-title">Attribute:</xhtml:p>
        <xhtml:dl>
          <xsl:for-each select="structDefinition/attribute[count(description)>0]" >
            <xsl:sort select="@name" />
            <!-- Label built from Class.method(paramtype,paramtype) -->
            <xhtml:dt><xsl:value-of select="@name"/> : <xsl:call-template name="typeName" /></xhtml:dt>
            <xhtml:dd>
              <xsl:copy-of select="description/brief/xhtml:body/*"/>
              <xsl:copy-of select="description/rest/xhtml:body/*"/>
            </xhtml:dd>
          </xsl:for-each>
        </xhtml:dl>
      </xsl:if>

      <!-- xsl:if test="count(Association/tag[@name='documentation'])>0" -->
      <xsl:if test="count(xxxAssociation)>0">
        <p>Assoziationen:</p>
        <table border="1" width="100%"><tr><th width="30%">Assoziation</th><th>Zielklasse</th><th>Beschreibung</th></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>
            <tr>
              <td><xsl:value-of select="@name"/></td>
              <td><internref label="{$LABEL}"><xsl:value-of select="@classType"/></internref></td>
              <td>
                <p expandWikistyle="true" style='standard'><xsl:value-of select="tag[@name='documentation']" /></p>
              </td>
            </tr>
          </xsl:for-each>
        </table>
      </xsl:if>
    </xhtml:body>

</xsl:template>




<xsl:template name="attributes-list">
<xsl:param name="className"/>
  <xhtml:dl>
    <xsl:for-each select="Cheader/class[@name=$className]/structDefinition/attribute">
      <xhtml:dt style="class-attribute">
        <xhtml:b><xsl:text>(?@name?): (?!type/@name?)(?if count(pointer)>0?)*(?/if?)(?if
          count(arraysize)>0?)[(?!arraysize/@value?)](?/if?) </xsl:text></xhtml:b>
        <xsl:value-of select="description/brief" /><xsl:text>. </xsl:text>
      </xhtml:dt>
      <xhtml:dd>
        <xsl:apply-templates select="description/rest/xhtml:body/*">
          <xsl:with-param name="pStyle" select="'class_text'" />
          <xsl:with-param name="ulStyle" select="'class_text_ul'" />
          <xsl:with-param name="olStyle" select="'class_text_ol'" />
          <xsl:with-param name="dlStyle" select="'class_text_dl'" />
          <xsl:with-param name="tableStyle" select="'class_text_table'" />
        </xsl:apply-templates>
      </xhtml:dd>
    </xsl:for-each>
  </xhtml:dl>
</xsl:template>


<xsl:template name="class-methods">
<xsl:param name="className"/>
  <xhtml:dl>
    <xsl:for-each select="Cheader/class[@name=$className]/methodDef[not(starts-with(@name,'constructor'))]">
      <xhtml:dt style="class-attribute">
        <xhtml:b><xsl:text>(?@name?): (?!type/@name?)(?if count(pointer)>0?)*(?/if?)(?if
          count(arraysize)>0?)[(?!arraysize/@value?)](?/if?) </xsl:text></xhtml:b>
        <xsl:value-of select="description/brief" /><xsl:text>. </xsl:text>
      </xhtml:dt>
      <xhtml:dd>
        <xsl:apply-templates select="description/rest/xhtml:body/*">
          <xsl:with-param name="pStyle" select="'class_text'" />
          <xsl:with-param name="ulStyle" select="'class_text_ul'" />
          <xsl:with-param name="olStyle" select="'class_text_ol'" />
          <xsl:with-param name="dlStyle" select="'class_text_dl'" />
          <xsl:with-param name="tableStyle" select="'class_text_table'" />
        </xsl:apply-templates>
      </xhtml:dd>
    </xsl:for-each>
  </xhtml:dl>
</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="sizeof">
<!-- returns the sizeof depends of the type -->
  <xsl:choose>
    <xsl:when test="count(type/@pointer)>0">4</xsl:when>
    <xsl:when test="count(type/@constPointer)>0">4</xsl:when>
    <xsl:when test="count(type/@volatilePointer)>0">4</xsl:when>
    <xsl:when test="type/@name='char'">1</xsl:when>
    <xsl:when test="type/@name='uint8'">1</xsl:when>
    <xsl:when test="type/@name='int8'">1</xsl:when>
    <xsl:when test="type/@name='int16'">2</xsl:when>
    <xsl:when test="type/@name='uint16'">2</xsl:when>
    <xsl:when test="type/@name='int32'">4</xsl:when>
    <xsl:when test="type/@name='uint32'">4</xsl:when>
    <xsl:when test="type/@name='float'">4</xsl:when>
    <xsl:when test="description/sizeof"><xsl:value-of select="description/sizeof/@sizeof" /></xsl:when>
    <xsl:when test="boolean(type/pointer) or boolean(type/constPointer) or boolean(type/volatilePointer)">4</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-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="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(arraysize)>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 a define in headerfile. The calling may be ransomed from generated DocuCtrl.xsl via
  GenDocuCtrl2Xsl.xsd -->
<!-- The presentation is sorted by define names. If some conditions are present, the same defines in several conditions
     are shown one after another.
 -->

<xsl:template name="oldheaderDefine">
<xsl:param name="name" select="'?'"/>
    <xhtml:body>
      <xsl:variable name="LABEL">define_<xsl:value-of select="@name"/></xsl:variable>
      <anchor label="{$LABEL}"/>
      <xhtml:p style="standard"><xhtml:u>Define: <xsl:value-of select="$name"/></xhtml:u></xhtml:p>
      <!-- common description(s) if some conditionBlock are present -->
      <xsl:for-each select="Cheader/DEFINE_C[@name=$name]"><xsl:copy-of
        select="structDefinition/description/brief/xhtml:body/*"/></xsl:for-each>
      <xsl:for-each select="Cheader/DEFINE_C[@name=$name]"><xsl:copy-of
        select="structDefinition/description/rest/xhtml:body/*"/></xsl:for-each>

      <!-- process every condition block, -->
      <xsl:for-each select="Cheader/DEFINE_C[@name=$name]/conditionBlock" >


      </xsl:for-each>

      <xsl:for-each select="Cheader/DEFINE_C[@name=$name]//defineDefinition" >
        <xsl:sort select="@name" />
        <!-- Label built from Class.method(paramtype,paramtype) -->
        <xsl:variable name="LABEL"><xsl:value-of select="@name"/></xsl:variable>
        <xhtml:dl>
          <xhtml:dt class="code"><xsl:value-of select="@name" />
          <xsl:text>((?call defineParam:"parameter"?))</xsl:text>
          </xhtml:dt>
          <xhtml:dd>
            <xsl:if test="local-name(..)='conditionBlock'">
              <xhtml:p>
                <xsl:text>#if </xsl:text>
                <xsl:for-each select="..//conditionDef">
                  <xsl:text>defined((?!.?)) </xsl:text>
                </xsl:for-each>
                <xsl:for-each select="..//conditionDefNot">
                  <xsl:text>!defined((?!.?)) </xsl:text>
                </xsl:for-each>
              </xhtml:p>
            </xsl:if>
            <xsl:if test="local-name(..)='elseConditionBlock'">
              <xhtml:p>
                <xsl:text>#if not </xsl:text>
                <xsl:for-each select="../..//conditionDef">
                  <xsl:text>defined((?!.?)) </xsl:text>
                </xsl:for-each>
                <xsl:for-each select="../..//conditionDefNot">
                  <xsl:text>!defined((?!.?)) </xsl:text>
                </xsl:for-each>
              </xhtml:p>
            </xsl:if>

            <xsl:copy-of select="description/brief/xhtml:body/*"/>
            <xsl:copy-of select="description/rest/xhtml:body/*"/>
          </xhtml:dd>
        </xhtml:dl>

      </xsl:for-each>

    </xhtml:body>

</xsl:template>

<xsl:template name="headerDefine">
<xsl:param name="name" select="'?'"/>
    <xhtml:body>
      <xsl:variable name="LABEL">define_<xsl:value-of select="@name"/></xsl:variable>
      <anchor label="{$LABEL}"/>
      <xhtml:p style="standard"><xhtml:u>Define: <xsl:value-of select="$name"/></xhtml:u></xhtml:p>
      <!-- common description(s) if some conditionBlock are present -->
      <xsl:for-each select="Cheader/DEFINE_C[@name=$name]">
        <xhtml:div expandWikistyle="true" class="umlDescription"><xsl:value-of select="description/text" /></xhtml:div>
      </xsl:for-each>

      <!-- process every condition block, -->
      <xhtml:dl>
        <!-- xsl:for-each select="Cheader/DEFINE_C[@name=$name]/conditionBlock/defineDefinition |
          Cheader/DEFINE_C[@name=$name]/defineDefinition" -->
        <xsl:for-each select="Cheader/DEFINE_C[@name=$name]//defineDefinition" >
          <xsl:sort select="@name" />
          <xsl:call-template name="showDefineDefinitionItem"><xsl:with-param name="conditional" select="''"
            /></xsl:call-template>
        </xsl:for-each>
      </xhtml:dl>
    </xhtml:body>

</xsl:template>



<xsl:template name="showDefineDefinitionItem">
<!-- Shows as dt-dd-item one DefineDefinition -->
<xsl:param name="conditional" select="''" />
  <xsl:variable name="LABEL"><xsl:value-of select="@name"/></xsl:variable>
  <xhtml:dt class="code"><xsl:value-of select="@name" />
  <xsl:text>((?call defineParam:"parameter"?))</xsl:text>
  </xhtml:dt>
  <xhtml:dd>
    <xsl:if test="$conditional!=''">
      <xhtml:p><xsl:value-of select="$conditional" /></xhtml:p>
    </xsl:if>
    <xsl:call-template name="showOrCondition" />
    <xhtml:div expandWikistyle="true" class="umlDescription"><xsl:value-of select="description/text" /></xhtml:div>
    <xsl:for-each select="xxx/../elseConditionBlock/defineDefinition">
      <!-- if it is in conditionBlock, now show the appropriate elif and else conditions.
        There won't be selected by the super for-each loop because the 'elseCondtionBlock' is not in select.
        -->  
      <xsl:call-template name="showDefineDefinitionItem"><xsl:with-param name="conditional" select="'#else'"
        /></xsl:call-template>
    </xsl:for-each>
    <!-- xsl:if test="local-name(..)='elseConditionBlock'">
      <xhtml:p>
        <xsl:text>#if not </xsl:text>
        <xsl:for-each select="../..//conditionDef">
          <xsl:text>defined(<@.>) </xsl:text>
        </xsl:for-each>
        <xsl:for-each select="../..//conditionDefNot">
          <xsl:text>!defined(<@.>) </xsl:text>
        </xsl:for-each>
      </xhtml:p>
    </xsl:if -->
  </xhtml:dd>
</xsl:template>


<xsl:template name="showOrCondition">
  <xsl:if test="local-name(..)='elseConditionBlock'">
    <xsl:for-each select="..">
      <xsl:call-template name="showOrCondition" /><!-- super condition -->
    </xsl:for-each>
    <xhtml:p><xsl:text>#else </xsl:text></xhtml:p>
  </xsl:if>
  <xsl:if test="local-name(..)='conditionBlock'">
    <xsl:for-each select="..">
      <xsl:call-template name="showOrCondition" /><!-- super condition -->
      <xhtml:p><xsl:text>#if </xsl:text>
        <xsl:for-each select="OrCondition">
          <xsl:call-template name="showAndCondition" />
          <xsl:text>(?ifNext?) || (?/if?)</xsl:text>
        </xsl:for-each>
        <xsl:call-template name="showAndCondition" />
        <xsl:call-template name="showCondition" />
      </xhtml:p>
    </xsl:for-each>
    <!-- First write the description outside the condition. -->
    <xhtml:div expandWikistyle="true" class="umlDescription"><xsl:value-of select="../description/text" /></xhtml:div>
  </xsl:if>
</xsl:template>  
    
      
<xsl:template name="showAndCondition">
  <xsl:for-each select="AndCondition">
    <xsl:call-template name="showCondition" />
    <xsl:text>(?ifNext?) &amp;&amp; (?/if?)</xsl:text>
  </xsl:for-each>
  <xsl:call-template name="showCondition" />
</xsl:template>


<xsl:template name="showCondition">
  <xsl:for-each select="conditionDefNot | conditionDef">
    <xsl:if test="local-name(.)='conditionDefNot'"><xsl:text>!defined(</xsl:text></xsl:if>
    <xsl:if test="local-name(.)='conditionDef'"><xsl:text>defined(</xsl:text></xsl:if>
    <xhtml:code><xsl:value-of select="." /></xhtml:code><xsl:text>)</xsl:text>
  </xsl:for-each>
</xsl:template>





<xsl:template name="defineParam">
  <xsl:value-of select="@name" />
  <xsl:if test="boolean(following-sibling)">
    <xsl:text>,</xsl:text>
  </xsl:if>
</xsl:template>


<xsl:template name="typeName">
  <xsl:value-of select="type/@name"/>
  <xsl:value-of select="type/@tagname"/><!-- either tagname or name will be present -->
  <xsl:choose><xsl:when test="count(type/@pointer)>0"><xsl:text>*</xsl:text></xsl:when>
    <xsl:when test="count(type/@constPointer)>0"><xsl:text> const*</xsl:text></xsl:when>
    <xsl:when test="count(type/@volatilePointer)>0"><xsl:text> volatile*</xsl:text></xsl:when>
  </xsl:choose>
  <xsl:if test="count(variante)>0"><xsl:text>union</xsl:text></xsl:if>
</xsl:template>



</xsl:stylesheet>