<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0">

  <xsl:variable name="titel">Documentatie Software Stage VCS'99 E.L.Willighagen</xsl:variable>

  <xsl:template match="*|@*">
    <b>Not yet Functional: <xsl:value-of select="."/></b>
  </xsl:template>

  <xsl:template match="/">
    <html>
      <head>
         <title><xsl:value-of select="$titel"/>: <xsl:value-of select="softpkg/name"/></title>
      </head>
      <body bgcolor="white">        
	<xsl:apply-templates/>
	
        <p align="center"><i><xsl:value-of select="$titel"/></i></p>
      </body>
    </html>
  </xsl:template>
  
  <xsl:template match="softpkg">
    <h3><xsl:value-of select="name"/></h3>
    <xsl:if test="./abstract">
      <p><b><i>Abstract:</i></b>: <xsl:apply-templates select="./abstract"/></p>
    </xsl:if>
    
    <xsl:for-each select="//distro">
      <xsl:sort select="./@version" order="descending"/>
      <xsl:apply-templates select="."/>
    </xsl:for-each>
  </xsl:template>

  <xsl:template match="abstract">
    <xsl:apply-templates/>
  </xsl:template>
  
  <xsl:template match="distro">
    <p><b>Release v<xsl:value-of select="./@version"/></b></p>
    <ul>
      <xsl:if test="release-date">
	<i>Released on</i>: <xsl:value-of select="release-date"/>
      </xsl:if>
      <p><b>Differences</b>
      <ul>
	<xsl:for-each select="diffs">
          <xsl:apply-templates select="."/>
	</xsl:for-each>
      </ul>
      </p>
    </ul>
  </xsl:template>

  <xsl:template match="diffs">
    <p><b><xsl:value-of select="./@type"/></b><br/>
    <xsl:for-each select=".//spec|.//depend|.//func|.//var">
      <xsl:sort select="./@name"/>
      <ul><xsl:call-template name="view"/></ul>
    </xsl:for-each>
    </p>
  </xsl:template>

  <xsl:template name="view">
    <xsl:apply-templates select="."/>
    <ul>
      <xsl:if test="./param">
	<p><b>parameters</b>:<br/><xsl:apply-templates select="param"/></p>
      </xsl:if>
      <xsl:if test="./returns">
	<p><xsl:apply-templates select="returns"/></p>
      </xsl:if>
      <xsl:if test="./desc">
	<p><xsl:apply-templates select="desc"/></p>
      </xsl:if>
      <xsl:if test="./remark">
	<p><xsl:apply-templates select="remark"/></p>
      </xsl:if>
    </ul>
  </xsl:template>    

  <xsl:template match="spec">
    <li/><i>Specification: </i><xsl:value-of select="./@name"/>
  </xsl:template>  

  <xsl:template match="depend">
    <li/><i>Dependency: </i><xsl:value-of select="./@name"/>
  </xsl:template>  

  <xsl:template match="func">
    <li/><i>Function: </i>
      <xsl:value-of select="./@name"/>
      <xsl:if test="./param">
        (
	<xsl:for-each select=".//param">
	  <xsl:value-of select="./@name"/>
	  <xsl:variable name="pos" select="position()+1"/>
	  <xsl:variable name="last" select="last()"/>
	  <xsl:if test="$pos=$last">, </xsl:if>
	</xsl:for-each>
	)
      </xsl:if>      
      <xsl:if test="./returns">
        -&gt; <xsl:value-of select="./returns/@type"/>
      </xsl:if>
  </xsl:template>  

  <xsl:template match="var">
    <li/><i>Variable: </i><xsl:value-of select="./@name"/>
  </xsl:template>
  
  <xsl:template match="desc">
    <b>description</b>: <xsl:apply-templates/>
  </xsl:template>  

  <xsl:template match="remark">
    <b>NB</b>! <xsl:apply-templates/>
  </xsl:template>  

  <xsl:template match="param">
    <xsl:value-of select="./@name"/>
    <xsl:if test="./@type">
      ( <i><xsl:value-of select="./@type"/></i> )
    </xsl:if>: <xsl:apply-templates/>
  </xsl:template>  

  <xsl:template match="returns">
    <b>returns</b>: <xsl:apply-templates/>
  </xsl:template>  

  <!-- the next elements are html elements and should be passed on -->

  <xsl:template match="desc//*|abstract//*|remark//*|param//*|returns//*|release-info//*">
     <xsl:copy>
       <xsl:apply-templates select="@*|node()"/>
     </xsl:copy>  
  </xsl:template>

  <xsl:template match="desc//*/@*|abstract//*/@*|remark//*/@*|param//*/@*|returns//*/@*|release-info//*/@*">
     <xsl:copy>
       <xsl:apply-templates select="@*|node()"/>
     </xsl:copy>  
  </xsl:template>

</xsl:stylesheet>
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0">

  <xsl:variable name="titel">Documentatie Software Stage VCS'99 E.L.Willighagen</xsl:variable>

  <xsl:template match="*|@*">
    <b>Not yet Functional: <xsl:value-of select="."/></b>
  </xsl:template>

  <xsl:template match="/">
    <html>
      <head>
         <title><xsl:value-of select="$titel"/>: <xsl:value-of select="softpkg/name"/></title>
      </head>
      <body bgcolor="white">        
	<xsl:apply-templates/>
	
        <p align="center"><i><xsl:value-of select="$titel"/></i></p>
      </body>
    </html>
  </xsl:template>
  
  <xsl:template match="softpkg">
    <h3><xsl:value-of select="name"/></h3>
    <xsl:if test="./abstract">
      <p><b><i>Abstract:</i></b>: <xsl:apply-templates select="./abstract"/></p>
    </xsl:if>
    
    <xsl:for-each select="//distro">
      <xsl:sort select="./@version" order="descending"/>
      <xsl:apply-templates select="."/>
    </xsl:for-each>
  </xsl:template>

  <xsl:template match="abstract">
    <xsl:apply-templates/>
  </xsl:template>
  
  <xsl:template match="distro">
    <p><b>Release v<xsl:value-of select="./@version"/></b></p>
    <ul>
      <xsl:if test="release-date">
	<i>Released on</i>: <xsl:value-of select="release-date"/>
      </xsl:if>
      <p><b>Differences</b>
      <ul>
	<xsl:for-each select="diffs">
          <xsl:apply-templates select="."/>
	</xsl:for-each>
      </ul>
      </p>
    </ul>
  </xsl:template>

  <xsl:template match="diffs">
    <p><b><xsl:value-of select="./@type"/></b><br/>
    <xsl:for-each select=".//spec|.//depend|.//func|.//var|.//object|.//bug">
      <xsl:sort select="./@name"/>
      <ul><xsl:call-template name="view"/></ul>
    </xsl:for-each>
    </p>
  </xsl:template>

  <xsl:template name="view">
    <xsl:apply-templates select="."/>
    <ul>
      <xsl:if test="./rel">
        <p>
        <xsl:for-each select=".//rel">
  	  <b>relation</b>: <xsl:apply-templates select="."/>
	</xsl:for-each>
	</p>
      </xsl:if>
      <xsl:if test="./param">
	<p><b>parameters</b>:<br/><xsl:apply-templates select="param"/></p>
      </xsl:if>
      <xsl:if test="./returns">
	<p><xsl:apply-templates select="returns"/></p>
      </xsl:if>
      <xsl:if test="./desc">
	<p><xsl:apply-templates select="desc"/></p>
      </xsl:if>
      <xsl:if test="./remark">
	<p><xsl:apply-templates select="remark"/></p>
      </xsl:if>
    </ul>
  </xsl:template>    

  <xsl:template match="spec">
    <li/><i>Specification: </i><xsl:value-of select="./@name"/>
  </xsl:template>  

  <xsl:template match="object">
    <li/><i>Object: </i><xsl:value-of select="./@name"/>      
  </xsl:template>  

  <xsl:template match="depend">
    <li/><i>Dependency: </i><xsl:value-of select="./@name"/>
  </xsl:template>  

  <xsl:template match="bug">
    <li/><i>Bug #</i><xsl:value-of select="./@id"/>
  </xsl:template>  

  <xsl:template match="func">
    <li/>
    <i>Function: </i>
      <xsl:value-of select="./@name"/>
      <xsl:if test="./param">
        (
	<xsl:for-each select=".//param">
	  <xsl:value-of select="./@name"/>
	  <xsl:variable name="pos" select="position()+1"/>
	  <xsl:variable name="last" select="last()"/>
	  <xsl:if test="$pos=$last">, </xsl:if>
	</xsl:for-each>
	)
      </xsl:if>      
      <xsl:if test="./returns">
        -&gt; <xsl:value-of select="./returns/@type"/>
      </xsl:if>
  </xsl:template>  

  <xsl:template match="var">
    <li/><i>Variable: </i><xsl:value-of select="./@name"/>
  </xsl:template>
  
  <xsl:template match="desc">
    <b>description</b>: <xsl:apply-templates/>
  </xsl:template>  

  <xsl:template match="remark">
    <b>NB</b>! <xsl:apply-templates/>
  </xsl:template>  

  <xsl:template match="rel">
    <xsl:value-of select="./@type"/><xsl:text> </xsl:text><xsl:apply-templates/>
  </xsl:template>  

  <xsl:template match="param">
    <xsl:value-of select="./@name"/>
    <xsl:if test="./@type">
      ( <i><xsl:value-of select="./@type"/></i> )
    </xsl:if>: <xsl:apply-templates/>
  </xsl:template>  

  <xsl:template match="returns">
    <b>returns</b>: <xsl:apply-templates/>
  </xsl:template>  

  <!-- the next elements are html elements and should be passed on -->

  <xsl:template match="desc//*|abstract//*|remark//*|param//*|returns//*|release-info//*">
     <xsl:copy>
       <xsl:apply-templates select="@*|node()"/>
     </xsl:copy>  
  </xsl:template>

  <xsl:template match="desc//*/@*|abstract//*/@*|remark//*/@*|param//*/@*|returns//*/@*|release-info//*/@*">
     <xsl:copy>
       <xsl:apply-templates select="@*|node()"/>
     </xsl:copy>  
  </xsl:template>

</xsl:stylesheet>
