<?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:topics="http://www.vishia.de/2006/Topics"
  xmlns:pre="http://www.vishia.de/2006/XhtmlPre"
  xmlns:xhtml="http://www.w3.org/1999/xhtml"
>
  <xsl:output method="html" encoding="iso-8859-1"/>

  <xs:annotation><xs:documentation type="versions">
    This file is included in all xsl files which proceeded a xml file based on xschema texttopic.xsd.
    Date       Who      Description of changing
    2005-12-14 hartmutS Initial-Revision
    2005-12-16 hartmutS chapterlevel as paramter for topic etc removed, not necessary because the realisation of the
                        chapter-nesting is done by PreHtml.xsl respective PreWord.xsl.
    2006-02-23 hartmutS changing of using of style.
    2006-02-25 hartmutS consequently selecting from child elements, no &lt;apply-templates />, always
      &lt;apply-templates select="..."/>
  </xs:documentation></xs:annotation>


  <!-- ................................................................................................. -->
  <!-- template to transform from topics or other xhtml-like xml-files into a PreHtml-Format ........... -->
  <!-- This script may be included in a user xsl-script. -->
  <!-- The input format may be matched to the TextTopic.xsd-schema,
       but may have some other things appropriately to the wrapping user script. -->
  <!-- The outputted format is matched to the PreHtml.xsd-schema -->

  <xsl:template match="topics:topic">
  <xsl:param name="divStyle" select="'-'" />
  <xsl:param name="pStyle" select="'-'" />
  <xsl:param name="ulStyle" select="'-'" />
  <xsl:param name="olStyle" select="'-'" />
  <xsl:param name="dlStyle" select="'-'" />
  <xsl:param name="tableStyle" select="'-'" />

  <xsl:param name="topicLabel">LABEL</xsl:param>
  <xsl:param name="topicIdent">/.../</xsl:param>
  <xsl:param name="paraStyle">standard</xsl:param>
  <xsl:param name="style_dt">standard_dtT</xsl:param>
  <xsl:param name="paraStyle_li">standard_li</xsl:param>
  <xsl:param name="paraStyle_tdli">standard_tdli</xsl:param>
  <xsl:param name="paraStyle_td">standard_td</xsl:param>
  <xsl:param name="paraStyle_th">standard_th</xsl:param>
  <xsl:param name="listStyle">listStandard</xsl:param>
  <xsl:param name="cellHeadStyle">tableHeadStanard</xsl:param>
  <xsl:param name="cellStyle">tableCellStandard</xsl:param>

    <xsl:variable name="topicLabelNew"><xsl:value-of select='$topicLabel'/>.<xsl:value-of
      select="@ident"/></xsl:variable>
    <xsl:variable name="topicIdentnew"><xsl:value-of select="$topicIdent"/>/<xsl:value-of
      select="@ident"/></xsl:variable>

    <xsl:choose>
    <xsl:when test="count(@title)>0 and string-length(@title)&gt;0">
      <!-- produce only a nested chapter if an attribute title is present -->
      <pre:chapter>
        <!-- anchor for hyperlink navigation: -->
        <xsl:if test="count(@label)>0">
          <xsl:variable name="topicLabelLocal">Topic=<xsl:value-of select='@label'/></xsl:variable>
          <anchor label="{$topicLabelLocal}"/>
        </xsl:if>
        <xsl:if test="count(./@label)=0">
          <anchor label="{$topicLabelNew}"/>
        </xsl:if>

        <pre:title><xsl:value-of select="@title"/></pre:title>
        <xsl:if test="count(@defineUnit)>0"><!-- topic with an attribute define is a define unit with references. -->
          <content>
            <!-- topic is a design element -->
            <table breakPage="noBreakAfter" border="1" width="100%">
              <tr><td><xsl:value-of select="@defineUnit"/></td></tr>
              <xsl:for-each select="tag[@name='ReqRef']">
                <xsl:variable name="reqAnchor">#<xsl:value-of select="@value"/></xsl:variable>
                <xsl:variable name="REQ"><xsl:value-of select="@value"/></xsl:variable>
                <xsl:variable name="reqElement" select="/root/Requirements/Requirement[@Ident=$REQ] |
                  /root/SwComponententSpec/NewRequirements/Requirement[@Ident=$REQ]"/>
                <tr><td>
                  <a href="{$reqAnchor}"><xsl:value-of select="$REQ"/> :
                  <xsl:value-of select="$reqElement/Titel"/></a>
                  <xsl:if test="count($reqElement/phase)>0"><i> (<xsl:value-of
                    select="$reqElement/phase"/>)</i></xsl:if>
                </td></tr>
              </xsl:for-each>
            </table>
          </content>
        </xsl:if>
        <xsl:call-template name="topicIntern" >
          <xsl:with-param name="divStyle"   select="$divStyle" />
          <xsl:with-param name="pStyle"     select="$pStyle" />
          <xsl:with-param name="ulStyle"    select="$ulStyle" />
          <xsl:with-param name="olStyle"    select="$olStyle" />
          <xsl:with-param name="dlStyle"    select="$dlStyle" />
          <xsl:with-param name="tableStyle" select="$tableStyle" />
        
          <xsl:with-param name="topicLabel"><xsl:value-of select='$topicLabelNew'/></xsl:with-param>
          <xsl:with-param name="topicIdent"><xsl:value-of select='$topicIdentnew'/></xsl:with-param>
          <xsl:with-param name="paraStyle"><xsl:value-of select='$paraStyle'/></xsl:with-param>
          <xsl:with-param name="style_dt" select="$style_dt"/>
          <xsl:with-param name="paraStyle_li" select="$paraStyle_li"/>
          <xsl:with-param name="paraStyle_th" select="$paraStyle_th"/>
          <xsl:with-param name="paraStyle_td" select="$paraStyle_td"/>
          <xsl:with-param name="paraStyle_tdli" select="$paraStyle_tdli"/>
          <xsl:with-param name="listStyle"><xsl:value-of select='$listStyle'/></xsl:with-param>
          <xsl:with-param name="cellHeadStyle"><xsl:value-of select='$cellHeadStyle'/></xsl:with-param>
          <xsl:with-param name="cellStyle"><xsl:value-of select='$cellStyle'/></xsl:with-param>
        </xsl:call-template>

      </pre:chapter>

    </xsl:when>
    <xsl:otherwise>
      <!-- no @title, no own pre:chapter -->

      <!-- anchor for hyperlink navigation: -->
      <xsl:if test="count(@label)>0">
        <xsl:variable name="topicLabelLocal">Topic=<xsl:value-of select='@label'/></xsl:variable>
        <anchor label="{$topicLabelLocal}"/>
      </xsl:if>
      <xsl:if test="count(./@label)=0">
        <anchor label="{$topicLabelNew}"/>
      </xsl:if>

      <xsl:call-template name="topicIntern" >
          <xsl:with-param name="divStyle"   select="$divStyle" />
          <xsl:with-param name="pStyle"     select="$pStyle" />
          <xsl:with-param name="ulStyle"    select="$ulStyle" />
          <xsl:with-param name="olStyle"    select="$olStyle" />
          <xsl:with-param name="dlStyle"    select="$dlStyle" />
          <xsl:with-param name="tableStyle" select="$tableStyle" />
        
        <xsl:with-param name="topicLabel"><xsl:value-of select='$topicLabelNew'/></xsl:with-param>
        <xsl:with-param name="topicIdent"><xsl:value-of select='$topicIdentnew'/></xsl:with-param>
        <xsl:with-param name="paraStyle"><xsl:value-of select='$paraStyle'/></xsl:with-param>
        <xsl:with-param name="style_dt" select="$style_dt"/>
        <xsl:with-param name="paraStyle_li" select="$paraStyle_li"/>
        <xsl:with-param name="paraStyle_th" select="$paraStyle_th"/>
        <xsl:with-param name="paraStyle_td" select="$paraStyle_td"/>
        <xsl:with-param name="paraStyle_tdli" select="$paraStyle_tdli"/>
        <xsl:with-param name="listStyle"><xsl:value-of select='$listStyle'/></xsl:with-param>
        <xsl:with-param name="cellHeadStyle"><xsl:value-of select='$cellHeadStyle'/></xsl:with-param>
        <xsl:with-param name="cellStyle"><xsl:value-of select='$cellStyle'/></xsl:with-param>
      </xsl:call-template>
    </xsl:otherwise>
    </xsl:choose>
  </xsl:template>



  <xsl:template name="topicIntern">
  <xsl:param name="divStyle" select="'-'" />
  <xsl:param name="pStyle" select="'-'" />
  <xsl:param name="ulStyle" select="'-'" />
  <xsl:param name="olStyle" select="'-'" />
  <xsl:param name="dlStyle" select="'-'" />
  <xsl:param name="tableStyle" select="'-'" />

  <xsl:param name="topicLabel">NO_REFLABEL_ONCALL</xsl:param>
  <xsl:param name="topicIdent">/i/</xsl:param>
  <xsl:param name="paraStyle">standard</xsl:param>
  <xsl:param name="style_dt">standard_dtTi</xsl:param>
  <xsl:param name="paraStyle_li">standard_li</xsl:param>
  <xsl:param name="paraStyle_tdli">standard_tdli</xsl:param>
  <xsl:param name="paraStyle_td">standard_td</xsl:param>
  <xsl:param name="paraStyle_th">standard_th</xsl:param>
  <xsl:param name="listStyle">listStandard</xsl:param>
  <xsl:param name="cellHeadStyle">tableCellHeadStandard</xsl:param>
  <xsl:param name="cellStyle">tableCellStandard</xsl:param>


    <xsl:if test='$testOutput&gt;2'>
      <testOutput level="3">[
        <xsl:if test="count(./@label)>0">Label:<xsl:value-of select='@label'/> Path:</xsl:if>
        <xsl:value-of select='$topicLabel' />]
      </testOutput>
    </xsl:if>

    <xsl:if test='$testOutput&gt;1'>
      <testOutput level="2">Topic=[<xsl:value-of select="$topicIdent" />]</testOutput>
    </xsl:if>

    <xsl:call-template name="topicContent"><!-- may be specified by user -->
          <xsl:with-param name="divStyle"   select="$divStyle" />
          <xsl:with-param name="pStyle"     select="$pStyle" />
          <xsl:with-param name="ulStyle"    select="$ulStyle" />
          <xsl:with-param name="olStyle"    select="$olStyle" />
          <xsl:with-param name="dlStyle"    select="$dlStyle" />
          <xsl:with-param name="tableStyle" select="$tableStyle" />
        
      <xsl:with-param name="topicLabel"><xsl:value-of select='$topicLabel'/></xsl:with-param>
      <xsl:with-param name="topicIdent"><xsl:value-of select='$topicIdent'/></xsl:with-param>
      <xsl:with-param name="paraStyle"><xsl:value-of select='$paraStyle'/></xsl:with-param>
      <xsl:with-param name="style_dt" select="$style_dt"/>
      <xsl:with-param name="paraStyle_li" select="$paraStyle_li"/>
      <xsl:with-param name="paraStyle_th" select="$paraStyle_th"/>
      <xsl:with-param name="paraStyle_td" select="$paraStyle_td"/>
      <xsl:with-param name="paraStyle_tdli" select="$paraStyle_tdli"/>
      <xsl:with-param name="listStyle"><xsl:value-of select='$listStyle'/></xsl:with-param>
      <xsl:with-param name="cellHeadStyle"><xsl:value-of select='$cellHeadStyle'/></xsl:with-param>
      <xsl:with-param name="cellStyle"><xsl:value-of select='$cellStyle'/></xsl:with-param>
    </xsl:call-template>

    <!-- sub pre:chapter or additinal content after the content at the own level -->
    <xsl:apply-templates select="topics:topic" >
          <xsl:with-param name="divStyle"   select="$divStyle" />
          <xsl:with-param name="pStyle"     select="$pStyle" />
          <xsl:with-param name="ulStyle"    select="$ulStyle" />
          <xsl:with-param name="olStyle"    select="$olStyle" />
          <xsl:with-param name="dlStyle"    select="$dlStyle" />
          <xsl:with-param name="tableStyle" select="$tableStyle" />
        
      <xsl:with-param name="topicLabel"><xsl:value-of select='$topicLabel'/></xsl:with-param>
      <xsl:with-param name="topicIdent"><xsl:value-of select='$topicIdent'/></xsl:with-param>
      <xsl:with-param name="paraStyle"><xsl:value-of select='$paraStyle'/></xsl:with-param>
      <xsl:with-param name="style_dt" select="$style_dt"/>
      <xsl:with-param name="paraStyle_li" select="$paraStyle_li"/>
      <xsl:with-param name="paraStyle_th" select="$paraStyle_th"/>
      <xsl:with-param name="paraStyle_td" select="$paraStyle_td"/>
      <xsl:with-param name="paraStyle_tdli" select="$paraStyle_tdli"/>
      <xsl:with-param name="listStyle"><xsl:value-of select='$listStyle'/></xsl:with-param>
      <xsl:with-param name="cellHeadStyle"><xsl:value-of select='$cellHeadStyle'/></xsl:with-param>
      <xsl:with-param name="cellStyle"><xsl:value-of select='$cellStyle'/></xsl:with-param>
    </xsl:apply-templates>

  </xsl:template>

                            
  <xsl:template name="assembleTopicAnchor">
  <!-- assembles the ident of all topics to root level in Form ".parent.child.child"
       therefore first a recursive call to parent will be done, after them the own ident will be added.
    -->    
    <xsl:if test="local-name(..)='topic'">
      <xsl:for-each select=".."><xsl:call-template name="assembleTopicAnchor" /></xsl:for-each>
    </xsl:if>      
    <xsl:text>.</xsl:text><xsl:value-of select="@ident" />  
  </xsl:template>
                            
                            
                            


  <xsl:template name="topicContent">
  <!-- this template method may be overloaded by a user specification if the user will shown its tag content
       in a special form. At example it is possible to show at first special tags via select="tag[@name='NAME']"
       and to show other tags inside text, via select="text|tag[@name='OTHERNAME']"
       In the standard specification all text and tag parts are converted in its common order.
  -->
  <xsl:param name="divStyle" select="'-'" />
  <xsl:param name="pStyle" select="'-'" />
  <xsl:param name="ulStyle" select="'-'" />
  <xsl:param name="olStyle" select="'-'" />
  <xsl:param name="dlStyle" select="'-'" />
  <xsl:param name="tableStyle" select="'-'" />

  <xsl:param name="topicLabel">NO_REFLABEL_ONCALL</xsl:param>
  <xsl:param name="topicIdent">/c/</xsl:param>
  <xsl:param name="paraStyle">-</xsl:param>
  <xsl:param name="style_dt">standard_dtTc</xsl:param>
  <xsl:param name="paraStyle_li">standard_li</xsl:param>
  <xsl:param name="paraStyle_tdli">standard_tdli</xsl:param>
  <xsl:param name="paraStyle_td">standard_td</xsl:param>
  <xsl:param name="paraStyle_th">standard_th</xsl:param>
  <xsl:param name="listStyle">-</xsl:param>
  <xsl:param name="cellHeadStyle">-</xsl:param>
  <xsl:param name="cellStyle">-</xsl:param>
    <xsl:if test="boolean(xhtml:body)>0">
      <xsl:variable name="topicId"><xsl:text>Topic</xsl:text><xsl:call-template name="assembleTopicAnchor"
        /></xsl:variable>
        <xsl:apply-templates select="xhtml:body" >
          <xsl:with-param name="id"         select="$topicId" />
          <xsl:with-param name="divStyle"   select="$divStyle" />
          <xsl:with-param name="pStyle"     select="$pStyle" />
          <xsl:with-param name="ulStyle"    select="$ulStyle" />
          <xsl:with-param name="olStyle"    select="$olStyle" />
          <xsl:with-param name="dlStyle"    select="$dlStyle" />
          <xsl:with-param name="tableStyle" select="$tableStyle" />
        
          <xsl:with-param name="topicLabel"><xsl:value-of select='$topicLabel'/></xsl:with-param>
          <xsl:with-param name="topicIdent"><xsl:value-of select='$topicIdent'/></xsl:with-param>
          <xsl:with-param name="paraStyle"><xsl:value-of select='$paraStyle'/></xsl:with-param>
          <xsl:with-param name="style_dt" select="$style_dt"/>
          <xsl:with-param name="paraStyle_li" select="$paraStyle_li"/>
          <xsl:with-param name="paraStyle_th" select="$paraStyle_th"/>
          <xsl:with-param name="paraStyle_td" select="$paraStyle_td"/>
          <xsl:with-param name="paraStyle_tdli" select="$paraStyle_tdli"/>
          <xsl:with-param name="listStyle"><xsl:value-of select='$listStyle'/></xsl:with-param>
          <xsl:with-param name="cellHeadStyle"><xsl:value-of select='$cellHeadStyle'/></xsl:with-param>
          <xsl:with-param name="cellStyle"><xsl:value-of select='$cellStyle'/></xsl:with-param>
        </xsl:apply-templates>

    </xsl:if>

  </xsl:template>



  <xsl:template match="tag">
  <!-- show a tag in topics in a universal form -->

    <!-- p><u>Tag:<xsl:value-of select="@name"/></u>=<xsl:value-of select="@value"/></p -->
  </xsl:template>








  <xsl:template match="xhtml:body">
  <xsl:param name="id" select="'-'" />
  <xsl:param name="divStyle" select="'-'" />
  <xsl:param name="pStyle" select="'-'" />
  <xsl:param name="ulStyle" select="'-'" />
  <xsl:param name="olStyle" select="'-'" />
  <xsl:param name="dlStyle" select="'-'" />
  <xsl:param name="tableStyle" select="'-'" />

  <xsl:param name="topicLabel">NO_REFLABEL_ONCALL</xsl:param>
  <xsl:param name="topicIdent">/b/</xsl:param>
  <xsl:param name="paraStyle">-</xsl:param>
  <xsl:param name="style_dt">standard_dtTc</xsl:param>
  <xsl:param name="paraStyle_li">standard_li</xsl:param>
  <xsl:param name="paraStyle_tdli">standard_tdli</xsl:param>
  <xsl:param name="paraStyle_td">standard_td</xsl:param>
  <xsl:param name="paraStyle_th">standard_th</xsl:param>
  <xsl:param name="listStyle">-</xsl:param>
  <xsl:param name="cellHeadStyle">-</xsl:param>
  <xsl:param name="cellStyle">-</xsl:param>
    <xhtml:body>
      <xsl:if test="$id!='-'"><xsl:attribute name="id"><xsl:value-of select="$id" /></xsl:attribute></xsl:if>
      <xsl:if test="$divStyle!='-'"><xsl:attribute name="class"><xsl:value-of select="$divStyle"
        /></xsl:attribute></xsl:if>
      <xsl:if test="name(..)='topics:topic'">
        <xhtml:p class="debug"><xsl:text>Topic=</xsl:text><xsl:call-template name="assembleTopicAnchor" /></xhtml:p>
      </xsl:if>
      <xhtml:p class="debug">
        <!-- xsl:text>Topic:</xsl:text><xsl:value-of select="$topicIdent"/ -->
        <!-- xsl:if test="not($paraStyle_li='-')"><xsl:text>paraStyle_li="</xsl:text><xsl:value-of
          select="$paraStyle_li"/><xsl:text>"; </xsl:text></xsl:if -->
        <!-- xsl:if test="not($listStyle='-')">   <xsl:text>listStyle="</xsl:text><xsl:value-of
          select="$listStyle"/><xsl:text>"; </xsl:text></xsl:if -->

        <xsl:if test="$divStyle!='-'"><xsl:text> divStyle=</xsl:text><xsl:value-of select="$divStyle"/></xsl:if>
        <xsl:if test="$pStyle!='-'"><xsl:text> pStyle=</xsl:text><xsl:value-of select="$pStyle"/></xsl:if>
        <xsl:if test="$ulStyle!='-'"><xsl:text> ulStyle=</xsl:text><xsl:value-of select="$ulStyle"/></xsl:if>
        <xsl:if test="$olStyle!='-'"><xsl:text> olStyle=</xsl:text><xsl:value-of select="$olStyle"/></xsl:if>
        <xsl:if test="$dlStyle!='-'"><xsl:text> dlStyle=</xsl:text><xsl:value-of select="$dlStyle"/></xsl:if>
        <xsl:if test="$tableStyle!='-'"><xsl:text> tableStyle=</xsl:text><xsl:value-of select="$tableStyle"/></xsl:if>
      </xhtml:p>
      <xsl:apply-templates >
          <xsl:with-param name="divStyle"   select="$divStyle" />
          <xsl:with-param name="pStyle"     select="$pStyle" />
          <xsl:with-param name="ulStyle"    select="$ulStyle" />
          <xsl:with-param name="olStyle"    select="$olStyle" />
          <xsl:with-param name="dlStyle"    select="$dlStyle" />
          <xsl:with-param name="tableStyle" select="$tableStyle" />
        
        <xsl:with-param name="topicLabel"><xsl:value-of select='$topicLabel'/></xsl:with-param>
        <xsl:with-param name="topicIdent"><xsl:value-of select='$topicIdent'/></xsl:with-param>
        <xsl:with-param name="paraStyle"><xsl:value-of select='$paraStyle'/></xsl:with-param>
        <xsl:with-param name="style_dt" select="$style_dt"/>
        <xsl:with-param name="paraStyle_li" select="$paraStyle_li"/>
        <xsl:with-param name="paraStyle_th" select="$paraStyle_th"/>
        <xsl:with-param name="paraStyle_td" select="$paraStyle_td"/>
        <xsl:with-param name="paraStyle_tdli" select="$paraStyle_tdli"/>
        <xsl:with-param name="listStyle"><xsl:value-of select='$listStyle'/></xsl:with-param>
        <xsl:with-param name="cellHeadStyle"><xsl:value-of select='$cellHeadStyle'/></xsl:with-param>
        <xsl:with-param name="cellStyle"><xsl:value-of select='$cellStyle'/></xsl:with-param>
      </xsl:apply-templates>
    </xhtml:body>

  </xsl:template>











  <!-- common templates for current text *********************************************** -->

  <xsl:template match="docuLink"><xsl:copy-of select="." /></xsl:template>

  <xsl:template match="picture">
    <img src="{@file}">
      <xsl:if test="count(@height)>0"><xsl:attribute name="height"><xsl:value-of
        select="@height"/></xsl:attribute></xsl:if>
      <xsl:if test="count(@width)>0"><xsl:attribute name="width"><xsl:value-of
        select="@width"/></xsl:attribute></xsl:if>
      <xsl:if test="count(@align)>0"><xsl:attribute name="align"><xsl:value-of
        select="@align"/></xsl:attribute></xsl:if>
      <xsl:if test="count(@title)>0"><xsl:attribute name="title"><xsl:value-of
        select="@title"/></xsl:attribute></xsl:if>
      <xsl:if test="following-sibling::*[1]/@name='picture'"><xsl:attribute name="title"><xsl:value-of
        select="following-sibling::*[1]/@value"/></xsl:attribute></xsl:if>
    </img>
  </xsl:template>

  <xsl:template match="xhtml:img">
    <xhtml:img src="{@src}">
      <xsl:if test="count(@height)>0"><xsl:attribute name="height"><xsl:value-of
        select="@height"/></xsl:attribute></xsl:if>
      <xsl:if test="count(@width)>0"><xsl:attribute name="width"><xsl:value-of
        select="@width"/></xsl:attribute></xsl:if>
      <xsl:if test="count(@align)>0"><xsl:attribute name="align"><xsl:value-of
        select="@align"/></xsl:attribute></xsl:if>
      <xsl:if test="count(@title)>0"><xsl:attribute name="title"><xsl:value-of
        select="@title"/></xsl:attribute></xsl:if>
      <xsl:if test="following-sibling::*[1]/@name='picture'"><xsl:attribute name="title"><xsl:value-of
        select="following-sibling::*[1]/@value"/></xsl:attribute></xsl:if>
    </xhtml:img>
  </xsl:template>

  <xsl:template match="textfile">
    <table border="0"><tr><td bgcolor="#e0e0e0">
      <xsl:copy-of select="." />
    </td></tr></table>
  </xsl:template>


  <xsl:template match="xhtml:p">
  <xsl:param name="pStyle" select="'-'" />
  <xsl:param name="paraStyle">standard</xsl:param>
    <xsl:variable name="style">
      <xsl:choose><xsl:when test="$pStyle!='-'"><xsl:value-of select="$pStyle"/></xsl:when>
      <xsl:when test="count(@class)>0 and @class!='-'"><xsl:value-of select="@class"/></xsl:when>
      <xsl:otherwise>standard</xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <!-- xsl:variable name="style">
      <xsl:choose><xsl:when test="count(@class)>0"><xsl:value-of select="@class"/></xsl:when>
      <xsl:otherwise><xsl:value-of select="$paraStyle"/></xsl:otherwise>
      </xsl:choose>
    </xsl:variable -->
    <xhtml:p class="{$style}"><xsl:apply-templates
      select="text()|xhtml:b|xhtml:i|xhtml:u|xhtml:br|xhtml:code|xhtml:span|xhtml:font|xhtml:a|xhtml:img" /></xhtml:p>
  </xsl:template>


  <!-- ********************************************************************************************* -->
  <!-- ********************************************************************************************* -->
  <!-- *********** Standard-conversion of a definition list ********************** -->

  <xsl:template match="xhtml:dl">
  <xsl:param name="divStyle" select="'-'" />
  <xsl:param name="pStyle" select="'-'" />
  <xsl:param name="ulStyle" select="'-'" />
  <xsl:param name="olStyle" select="'-'" />
  <xsl:param name="dlStyle" select="'-'" />
  <xsl:param name="tableStyle" select="'-'" />

  <xsl:param name="style_dl">standard_dl</xsl:param>
  <xsl:param name="paraStyle">standard</xsl:param>
  <xsl:param name="style_dt">standard_dtdl</xsl:param>
  <xsl:param name="paraStyle_tdli">standard_litd</xsl:param>
  <xsl:param name="paraStyle_td">standard_td</xsl:param>
  <xsl:param name="paraStyle_th">standard_th</xsl:param>
  <xsl:param name="listStyle">listStandard</xsl:param>
  <xsl:param name="cellHeadStyle">tableHeadStanard</xsl:param>
  <xsl:param name="cellStyle">tableCellStandard</xsl:param>
    <xhtml:dl style="{$tableStyle}">
      <xsl:apply-templates select="xhtml:dt|xhtml:dd" >
          <xsl:with-param name="divStyle"   select="$divStyle" />
          <xsl:with-param name="pStyle"     select="$pStyle" />
          <xsl:with-param name="ulStyle"    select="$ulStyle" />
          <xsl:with-param name="olStyle"    select="$olStyle" />
          <xsl:with-param name="dlStyle"    select="$dlStyle" />
          <xsl:with-param name="tableStyle" select="$tableStyle" />
        
        <xsl:with-param name="style_dt" select="$style_dt"/><!-- paragraph in table with paraStyle_td! -->
        <xsl:with-param name="listStyle" select="$listStyle"/>
        <xsl:with-param name="cellHeadStyle" select="$cellHeadStyle"/>
        <xsl:with-param name="cellStyle" select="$cellStyle"/>
      </xsl:apply-templates>
    </xhtml:dl>
  </xsl:template>




  <xsl:template match="xhtml:dt">
  <xsl:param name="style_dt">standard_dt</xsl:param>
    <xsl:variable name="style">
      <xsl:choose><xsl:when test="count(@class)>0"><xsl:value-of select="@class"/></xsl:when>
      <xsl:otherwise><xsl:value-of select="$style_dt"/></xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xhtml:dt class="{$style}"><xsl:apply-templates
      select="text()|xhtml:b|xhtml:i|xhtml:u|xhtml:br|xhtml:code|xhtml:span|xhtml:font|xhtml:a" /></xhtml:dt>
  </xsl:template>


  <xsl:template match="xhtml:dd">
  <xsl:param name="divStyle" select="'-'" />
  <xsl:param name="pStyle" select="'-'" />
  <xsl:param name="ulStyle" select="'-'" />
  <xsl:param name="olStyle" select="'-'" />
  <xsl:param name="dlStyle" select="'-'" />
  <xsl:param name="tableStyle" select="'-'" />

  <xsl:param name="style_dt" select='style_tddd'/>
  <xsl:param name="paraStyle_tdli">standard_litd</xsl:param>
  <xsl:param name="paraStyle_td">standard_td</xsl:param>
  <xsl:param name="paraStyle_th">standard_th</xsl:param>
  <xsl:param name="listStyle">listStandard</xsl:param>
  <xsl:param name="cellHeadStyle">tableHeadStanard</xsl:param>
  <xsl:param name="cellStyle">tableCellStandard</xsl:param>
    <xhtml:dd style="{$tableStyle}">
      <xsl:apply-templates>
          <xsl:with-param name="divStyle"   select="$divStyle" />
          <xsl:with-param name="pStyle"     select="$pStyle" />
          <xsl:with-param name="ulStyle"    select="$ulStyle" />
          <xsl:with-param name="olStyle"    select="$olStyle" />
          <xsl:with-param name="dlStyle"    select="$dlStyle" />
          <xsl:with-param name="tableStyle" select="$tableStyle" />
        
        <xsl:with-param name="paraStyle" select="$paraStyle_td"/><!-- paragraph in table with paraStyle_td! -->
        <xsl:with-param name="style_dt" select="$style_dt"/>
        <xsl:with-param name="listStyle" select="$listStyle"/>
        <xsl:with-param name="cellHeadStyle" select="$cellHeadStyle"/>
        <xsl:with-param name="cellStyle" select="$cellStyle"/>
      </xsl:apply-templates>
    </xhtml:dd>
  </xsl:template>






  <xsl:template match="xhtml:br">
    <br/>
  </xsl:template>



  <xsl:template match="xhtml:i"><xhtml:i><xsl:apply-templates /></xhtml:i></xsl:template>
  <xsl:template match="xhtml:u"><xhtml:u><xsl:apply-templates /></xhtml:u></xsl:template>
  <xsl:template match="xhtml:b"><xhtml:b><xsl:apply-templates /></xhtml:b></xsl:template>
  <xsl:template match="xhtml:code"><xhtml:code><xsl:apply-templates /></xhtml:code></xsl:template>

  <xsl:template match="xhtml:pre">
    <xhtml:table border="0"><xhtml:tr><xhtml:td bgcolor="#FFFFa0">
      <xsl:copy-of select="." />
    </xhtml:td></xhtml:tr></xhtml:table>
  </xsl:template>


  <xsl:template match="xhtml:span">
    <xsl:choose><xsl:when test="@class='inset'">
      <xsl:variable name="insetTopic" select="/root/GenCtrl/document/inset/topic/@select" />
      <xsl:for-each select="/root/Topics">
			  <xsl:call-template name="selectInset">
	  			<xsl:with-param name="select" select="$insetTopic" />
  		  </xsl:call-template>
		  </xsl:for-each>
		  <!-- xsl:for-each select="/.//topics:topic[@ident='TestInset']/xhtml:body/xhtml:p">
  	    <xsl:apply-templates select="text()|*" />
      </xsl:for-each -->
		  <xhtml:u>(INSET:<xsl:value-of select="$insetTopic" />:</xhtml:u>
	  </xsl:when><xsl:otherwise>
      <xhtml:span class="{@class}">
		    <xsl:apply-templates />
		  </xhtml:span>
	  </xsl:otherwise></xsl:choose>
  </xsl:template>



  <xsl:template name="selectInset">
	<xsl:param name="select" />
	  <xsl:variable name="select1" select="substring-before($select,'/')" />
	  <xsl:choose><xsl:when test="string-length($select1)>0">
      <xsl:for-each select="topics:topic[@ident=$select1]">
			  <xsl:call-template name="selectInset">
				  <xsl:with-param name="select" select="substring-after($select,'/')" />
			  </xsl:call-template>
			</xsl:for-each>  
	  </xsl:when><xsl:otherwise>
      <xsl:for-each select="topics:topic[@ident=$select]/xhtml:body/xhtml:p">
  	    <xsl:apply-templates select="text()|*" />
      </xsl:for-each>
		</xsl:otherwise></xsl:choose>
  </xsl:template>


  <xsl:template match="xhtml:ul">
  <xsl:param name="divStyle" select="'-'" />
  <xsl:param name="pStyle" select="'-'" />
  <xsl:param name="ulStyle" select="'-'" />
  <xsl:param name="olStyle" select="'-'" />
  <xsl:param name="dlStyle" select="'-'" />
  <xsl:param name="tableStyle" select="'-'" />

  <xsl:param name="paraStyle_li">standard_li</xsl:param>
  <xsl:param name="paraStyle_tdli">standard_tdli</xsl:param>
  <xsl:param name="listStyle">listStandard</xsl:param>
  <xsl:param name="cellHeadStyle">tableHeadStanard</xsl:param>
  <xsl:param name="cellStyle">tableCellStandard</xsl:param>
    <xsl:variable name="style">
      <xsl:choose><xsl:when test="$ulStyle!='-'"><xsl:value-of select="$ulStyle"/></xsl:when>
      <xsl:when test="count(@class)>0 and @class!='-'"><xsl:value-of select="@class"/></xsl:when>
      <xsl:otherwise>liStandard</xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xhtml:ul class="{$style}">
      <!-- xsl:apply-templates select="li" ><xsl:with-param
        name="listStyle">listIntern</xsl:with-param></xsl:apply-templates -->
      <xsl:apply-templates select="xhtml:li" >
          <xsl:with-param name="divStyle"   select="$divStyle" />
          <xsl:with-param name="pStyle"     select="$pStyle" />
          <xsl:with-param name="ulStyle"    select="$ulStyle" />
          <xsl:with-param name="olStyle"    select="$olStyle" />
          <xsl:with-param name="dlStyle"    select="$dlStyle" />
          <xsl:with-param name="tableStyle" select="$tableStyle" />
        
        <xsl:with-param name="paraStyle_li" select="$paraStyle_li"/>
        <xsl:with-param name="listStyle" select="$listStyle"/>
        <xsl:with-param name="cellHeadStyle" select="$cellHeadStyle"/>
        <xsl:with-param name="cellStyle" select="$cellStyle"/>
      </xsl:apply-templates>
    </xhtml:ul>
  </xsl:template>



  <xsl:template match="xhtml:li">
  <xsl:param name="divStyle" select="'-'" />
  <xsl:param name="pStyle" select="'-'" />
  <xsl:param name="ulStyle" select="'-'" />
  <xsl:param name="olStyle" select="'-'" />
  <xsl:param name="dlStyle" select="'-'" />
  <xsl:param name="tableStyle" select="'-'" />

  <xsl:param name="paraStyle_li">standard_li</xsl:param>
  <xsl:param name="paraStyle_tdli">standard_tdli</xsl:param>
  <xsl:param name="paraStyle_td">standard_td</xsl:param>
  <xsl:param name="paraStyle_th">standard_th</xsl:param>
  <xsl:param name="listStyle">listStandard</xsl:param>
  <xsl:param name="cellHeadStyle">tableHeadStanard</xsl:param>
  <xsl:param name="cellStyle">tableCellStandard</xsl:param>
    <xhtml:li>
      <xsl:if test="string-length(normalize-space(text()))>0">
        <!-- if the li contents direct formated or non formated text, a p-tag will set arround. -->
        <p style="{$paraStyle_li}"><!-- paragraph in list with paraStyle_li! -->
          <xsl:apply-templates  select="text()|xhtml:b|xhtml:i|xhtml:u|xhtml:br|xhtml:code|xhtml:font|xhtml:a">
          </xsl:apply-templates>
        </p>
      </xsl:if>
      <xsl:apply-templates select="xhtml:p|xhtml:ul|xhtml:ol|xhtml:dl|xhtml:table|xhtml:img">
          <xsl:with-param name="pStyle"><xsl:value-of select="$ulStyle"/><xsl:if
            test="$ulStyle!='-'">_p</xsl:if></xsl:with-param>
          <xsl:with-param name="ulStyle"    select="$ulStyle" />
          <xsl:with-param name="olStyle"    select="$olStyle" />
          <xsl:with-param name="dlStyle"    select="$dlStyle" />
          <xsl:with-param name="tableStyle" select="$tableStyle" />
        
        <xsl:with-param name="paraStyle" select="$paraStyle_li"/><!-- paragraph in list with paraStyle_li! -->
        <xsl:with-param name="listStyle" select="$listStyle"/>
        <xsl:with-param name="cellHeadStyle" select="$cellHeadStyle"/>
        <xsl:with-param name="cellStyle" select="$cellStyle"/>
      </xsl:apply-templates>
    </xhtml:li>
  </xsl:template>






  <!-- ********************************************************************************************* -->
  <!-- ********************************************************************************************* -->
  <!-- *********** Standard-Konvertierung einer table mit tabhead und tabline ********************** -->

  <xsl:template match="xhtml:table">
  <xsl:param name="divStyle" select="'-'" />
  <xsl:param name="pStyle" select="'-'" />
  <xsl:param name="ulStyle" select="'-'" />
  <xsl:param name="olStyle" select="'-'" />
  <xsl:param name="dlStyle" select="'-'" />
  <xsl:param name="tableStyle" select="'-'" />

  <xsl:param name="paraStyle_tdli">standard_litd</xsl:param>
  <xsl:param name="paraStyle_td">standard_td</xsl:param>
  <xsl:param name="paraStyle_th">standard_th</xsl:param>
  <xsl:param name="listStyle">listStandard</xsl:param>
  <xsl:param name="cellHeadStyle">tableHeadStanard</xsl:param>
  <xsl:param name="cellStyle">tableCellStandard</xsl:param>
    <xsl:if test="count(@title)>0">
      <!-- p xml:space="preserve" --><p><b>Tabelle:</b> <xsl:value-of select="@title"/></p>
    </xsl:if>
    <xsl:variable name="style">
      <xsl:choose><xsl:when test="$tableStyle!='-'"><xsl:value-of select="$tableStyle"/></xsl:when>
      <xsl:when test="count(@class)>0 and @class!='-'"><xsl:value-of select="@class"/></xsl:when>
      <xsl:otherwise>tabStandard</xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xhtml:table class="{$style}">
      <xsl:apply-templates select="xhtml:tr" >
          <xsl:with-param name="divStyle"   select="$divStyle" />
          <xsl:with-param name="pStyle"     select="$pStyle" />
          <xsl:with-param name="ulStyle"    select="$ulStyle" />
          <xsl:with-param name="olStyle"    select="$olStyle" />
          <xsl:with-param name="dlStyle"    select="$dlStyle" />
          <xsl:with-param name="tableStyle" select="$tableStyle" />
        
        <xsl:with-param name="paraStyle" select="$paraStyle_td"/><!-- paragraph in table with paraStyle_td! -->
        <xsl:with-param name="listStyle" select="$listStyle"/>
        <xsl:with-param name="cellHeadStyle" select="$cellHeadStyle"/>
        <xsl:with-param name="cellStyle" select="$cellStyle"/>
      </xsl:apply-templates>
    </xhtml:table>
  </xsl:template>


  <xsl:template match="xhtml:tr">
  <xsl:param name="divStyle" select="'-'" />
  <xsl:param name="pStyle" select="'-'" />
  <xsl:param name="ulStyle" select="'-'" />
  <xsl:param name="olStyle" select="'-'" />
  <xsl:param name="dlStyle" select="'-'" />
  <xsl:param name="tableStyle" select="'-'" />

  <xsl:param name="paraStyle_tdli">standard_litd</xsl:param>
  <xsl:param name="paraStyle_td">standard_td</xsl:param>
  <xsl:param name="paraStyle_th">standard_th</xsl:param>
  <xsl:param name="listStyle">listStandard</xsl:param>
  <xsl:param name="cellHeadStyle">tableHeadStanard</xsl:param>
  <xsl:param name="cellStyle">tableCellStandard</xsl:param>
    <xhtml:tr>
      <xsl:apply-templates select="xhtml:th|xhtml:td" >
          <xsl:with-param name="divStyle"   select="$divStyle" />
          <xsl:with-param name="pStyle"     select="$pStyle" />
          <xsl:with-param name="ulStyle"    select="$ulStyle" />
          <xsl:with-param name="olStyle"    select="$olStyle" />
          <xsl:with-param name="dlStyle"    select="$dlStyle" />
          <xsl:with-param name="tableStyle" select="$tableStyle" />
        
        <xsl:with-param name="paraStyle_th" select="$paraStyle_th"/>
        <xsl:with-param name="paraStyle_td" select="$paraStyle_td"/>
        <xsl:with-param name="paraStyle_tdli" select="$paraStyle_tdli"/>
        <xsl:with-param name="listStyle" select="$listStyle"/>
        <xsl:with-param name="cellHeadStyle" select="$cellHeadStyle"/>
        <xsl:with-param name="cellStyle" select="$cellStyle"/>
      </xsl:apply-templates>
    </xhtml:tr>
  </xsl:template>



  <xsl:template match="xhtml:th">
  <xsl:param name="divStyle" select="'-'" />
  <xsl:param name="pStyle" select="'-'" />
  <xsl:param name="ulStyle" select="'-'" />
  <xsl:param name="olStyle" select="'-'" />
  <xsl:param name="dlStyle" select="'-'" />
  <xsl:param name="tableStyle" select="'-'" />

  <xsl:param name="paraStyle_tdli">standard_litd</xsl:param>
  <xsl:param name="paraStyle_td">standard_td</xsl:param>
  <xsl:param name="paraStyle_th">standard_th</xsl:param>
  <xsl:param name="listStyle">listStandard</xsl:param>
  <xsl:param name="cellHeadStyle">tableHeadStanard</xsl:param>
  <xsl:param name="cellStyle">tableCellStandard</xsl:param>
    <xhtml:td style="{$cellHeadStyle}">
      <xsl:apply-templates>
          <xsl:with-param name="divStyle"   select="$divStyle" />
          <xsl:with-param name="pStyle"     select="$pStyle" />
          <xsl:with-param name="ulStyle"    select="$ulStyle" />
          <xsl:with-param name="olStyle"    select="$olStyle" />
          <xsl:with-param name="dlStyle"    select="$dlStyle" />
          <xsl:with-param name="tableStyle" select="$tableStyle" />
        
        <xsl:with-param name="paraStyle" select="$paraStyle_th"/><!-- paragraph in table head with paraStyle_th! -->
        <xsl:with-param name="paraStyle_th" select="$paraStyle_th"/>
        <xsl:with-param name="paraStyle_td" select="$paraStyle_td"/>
        <xsl:with-param name="paraStyle_tdli" select="$paraStyle_tdli"/>
        <xsl:with-param name="listStyle" select="$listStyle"/>
        <xsl:with-param name="cellHeadStyle" select="$cellHeadStyle"/>
        <xsl:with-param name="cellStyle" select="$cellStyle"/>
      </xsl:apply-templates>
    </xhtml:td>
  </xsl:template>



  <xsl:template match="xhtml:td">
  <xsl:param name="divStyle" select="'-'" />
  <xsl:param name="pStyle" select="'-'" />
  <xsl:param name="ulStyle" select="'-'" />
  <xsl:param name="olStyle" select="'-'" />
  <xsl:param name="dlStyle" select="'-'" />
  <xsl:param name="tableStyle" select="'-'" />

  <xsl:param name="paraStyle_tdli">standard_litd</xsl:param>
  <xsl:param name="paraStyle_td">standard_td</xsl:param>
  <xsl:param name="paraStyle_th">standard_th</xsl:param>
  <xsl:param name="listStyle">listStandard</xsl:param>
  <xsl:param name="cellHeadStyle">tableHeadStanard</xsl:param>
  <xsl:param name="cellStyle">tableCellStandard</xsl:param>
    <xhtml:td style="{$cellStyle}">
      <xsl:apply-templates>
          <xsl:with-param name="divStyle"   select="$divStyle" />
          <xsl:with-param name="pStyle"     select="$pStyle" />
          <xsl:with-param name="ulStyle"    select="$ulStyle" />
          <xsl:with-param name="olStyle"    select="$olStyle" />
          <xsl:with-param name="dlStyle"    select="$dlStyle" />
          <xsl:with-param name="tableStyle" select="$tableStyle" />
        
        <xsl:with-param name="paraStyle" select="$paraStyle_td"/><!-- paragraph in table cell with paraStyle_td! -->
        <xsl:with-param name="paraStyle_th" select="$paraStyle_th"/>
        <xsl:with-param name="paraStyle_td" select="$paraStyle_td"/>
        <xsl:with-param name="paraStyle_tdli" select="$paraStyle_tdli"/>
        <xsl:with-param name="listStyle" select="$listStyle"/>
        <xsl:with-param name="cellHeadStyle" select="$cellHeadStyle"/>
        <xsl:with-param name="cellStyle" select="$cellStyle"/>
      </xsl:apply-templates>
    </xhtml:td>
  </xsl:template>





  <!-- ********************************************************************************************* -->
  <!-- ********************************************************************************************* -->
  <!-- Alles für Querverweise und Literaturangaben :diesen Kommentar stehenlassen für Dokugenerierung! -->

  <xsl:template match="a"><!-- html-like anchor -->
    <xsl:message>invalid element &lt;a> </xsl:message>
    <xsl:if test="count(@href)>0 and starts-with(@href,'#')">
      <xsl:variable name="label"><xsl:value-of select="substring(@href,2)"/></xsl:variable><!-- label without the # !
        -->
      <internref label="{$label}"><xsl:apply-templates/></internref>
    </xsl:if>
    <xsl:if test="count(@href)>0 and not(starts-with(@href,'#'))">
      <fileref name="{@href}"><xsl:apply-templates/></fileref>
    </xsl:if>
    <xsl:if test="count(@name)>0">
      <anchor label="{@name}"/>
    </xsl:if>
  </xsl:template>


  <xsl:template match="xhtml:xxxa">
    <xsl:if test="count(@href)>0 and starts-with(@href,'#')">
      <xsl:variable name="label"><xsl:value-of select="substring(@href,2)"/></xsl:variable><!-- label without the # !
        -->
      <internref label="{$label}"><xsl:apply-templates/></internref>
    </xsl:if>
    <xsl:if test="count(@href)>0 and not(starts-with(@href,'#'))">
      <fileref name="{@href}"><xsl:apply-templates/></fileref>
    </xsl:if>
    <xsl:if test="count(@name)>0">
      <anchor label="{@name}"/>
    </xsl:if>
  </xsl:template>

  <xsl:template match="xhtml:a">
    <xhtml:a href="{@href}"><xsl:apply-templates/></xhtml:a>
  </xsl:template>

  <xsl:template match="fileref">
  <!-- a fileref is a hyperlink to a external file. -->
    <fileref name="{@name}"><xsl:apply-templates/></fileref>
  </xsl:template>

  <xsl:template match="internref">
  <!-- a internref is a hyperlink to a label. -->
    <internref label="{@label}"><xsl:apply-templates/></internref>
  </xsl:template>





</xsl:stylesheet>