<?xml version="1.0" encoding="utf-8"?>

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

<xsl:output
    method="xml"
    encoding="utf-8"
    indent="yes"/>

<xsl:template match="log">
  <revhistory>
    <xsl:apply-templates>
      <xsl:sort select="@revision" order="descending" data-type="number"/>
    </xsl:apply-templates>
  </revhistory>
</xsl:template>

<xsl:template match="logentry">
  <revision>
    <revnumber><xsl:value-of select="@revision"/></revnumber>
    <date><xsl:call-template name="format-date">
      <xsl:with-param name="date">
        <xsl:value-of select="date"/>
      </xsl:with-param>
    </xsl:call-template></date>
    <authorinitials><xsl:value-of select="author"/></authorinitials>
    <xsl:apply-templates select="msg"/>
  </revision>
</xsl:template>

<xsl:template match="msg">
    <revdescription><literallayout><xsl:value-of select="text()"/></literallayout></revdescription>
</xsl:template>

<xsl:template name="format-date">
    <xsl:param name="date"/>
<!-- this template expects the date to be of the correct format -->
    <xsl:value-of select="substring-before($date,'T')"/>
    <xsl:text> </xsl:text>
    <xsl:value-of select="substring-before(substring-after($date,'T'),'.')"/>
</xsl:template>

</xsl:stylesheet>

