<?xml version='1.0'?> <!-- -*- nxml -*- -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:fm="http://freshmeat.net/projects/freshmeat-submit/"
		xmlns:sf="http://sourceforge.net/"
		exclude-result-prefixes="fm sf"
                version='1.0'>

<xsl:param name="SLIDES-VERSION" select="string(document('')//fm:Version[1])"/>
<xsl:param name="sf-relid" select="0"/>
<xsl:strip-space elements="fm:*"/>

<fm:project>
  <fm:Project>DocBook</fm:Project>
  <fm:Branch>Slides</fm:Branch>
  <fm:Version>3.3.1</fm:Version>
  <fm:Release-Focus>
  <!-- initial freshmeat announcement -->
  <!-- documentation -->
  <!-- code cleanup -->
  <!-- minor feature enhancements -->
  <!-- major feature enhancements -->
  <!-- minor bugfixes -->
  major bugfixes
  <!-- minor security fixes -->
  <!-- major security fixes -->
  </fm:Release-Focus>
  <fm:Home-Page-URL>http://sourceforge.net/projects/docbook/</fm:Home-Page-URL>
  <fm:Gzipped-Tar-URL>http://prdownloads.sourceforge.net/docbook/slides-{VERSION}.tar.gz?download</fm:Gzipped-Tar-URL>
  <fm:Zipped-Tar-URL>http://prdownloads.sourceforge.net/docbook/slides-{VERSION}.zip?download</fm:Zipped-Tar-URL>
  <fm:Changelog-URL>http://sourceforge.net/project/shownotes.php?release_id={SFRELID}</fm:Changelog-URL>
  <fm:CVS-URL>http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/docbook/slides/</fm:CVS-URL>
  <fm:Mailing-List-URL>http://lists.oasis-open.org/archives/docbook-apps/</fm:Mailing-List-URL>
  <fm:Changes>Fixed root template priority issue that sometimes
caused the stylesheets to fail completely.
</fm:Changes>
</fm:project>

<xsl:template match="/" priority="-100">
  <xsl:choose>
    <xsl:when test="xsl:*">
      <xsl:if test="$sf-relid = 0">
	<xsl:message terminate="yes">
	  <xsl:text>You must specify the sf-relid as a parameter.</xsl:text>
	</xsl:message>
      </xsl:if>

      <xsl:apply-templates select="//fm:project"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:apply-imports/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<xsl:template match="fm:project">
  <xsl:text>&#10;</xsl:text>
  <xsl:apply-templates/>
  <xsl:text>&#10;</xsl:text>
  <xsl:apply-templates select="fm:Changes" mode="text"/>
</xsl:template>

<xsl:template match="fm:Changes"/>

<xsl:template match="fm:*">
  <xsl:value-of select="local-name(.)"/>
  <xsl:text>: </xsl:text>
  <xsl:call-template name="value">
    <xsl:with-param name="text" select="normalize-space(.)"/>
  </xsl:call-template>
  <xsl:text>&#10;</xsl:text>
</xsl:template>

<xsl:template name="value">
  <xsl:param name="text"/>

  <xsl:variable name="sub-version">
    <xsl:call-template name="string.subst">
      <xsl:with-param name="string" select="$text"/>
      <xsl:with-param name="target" select="'{VERSION}'"/>
      <xsl:with-param name="replacement" select="$SLIDES-VERSION"/>
    </xsl:call-template>
  </xsl:variable>

  <xsl:call-template name="string.subst">
    <xsl:with-param name="string" select="$sub-version"/>
    <xsl:with-param name="target" select="'{SFRELID}'"/>
    <xsl:with-param name="replacement" select="$sf-relid"/>
  </xsl:call-template>
</xsl:template>

<xsl:template name="string.subst">
  <xsl:param name="string"/>
  <xsl:param name="target"/>
  <xsl:param name="replacement"/>

  <xsl:choose>
    <xsl:when test="contains($string, $target)">
      <xsl:variable name="rest">
        <xsl:call-template name="string.subst">
          <xsl:with-param name="string" select="substring-after($string, $target)"/>
          <xsl:with-param name="target" select="$target"/>
          <xsl:with-param name="replacement" select="$replacement"/>
        </xsl:call-template>
      </xsl:variable>
      <xsl:value-of select="concat(substring-before($string, $target),
                                   $replacement,
                                   $rest)"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$string"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

</xsl:stylesheet>
