diff options
author | Andrei Belov <defan@nginx.com> | 2020-12-08 13:17:21 +0300 |
---|---|---|
committer | Andrei Belov <defan@nginx.com> | 2020-12-08 13:17:21 +0300 |
commit | 12a0d259a50fd6feef46aeffa0e46e193ce6bb40 (patch) | |
tree | 8fdf76a7898e18a6389ab6260b19f9678593db10 /docs/changes.xslt | |
parent | 2348229dc7656f36a7915d85af56aae9ed9fb120 (diff) | |
download | unit-12a0d259a50fd6feef46aeffa0e46e193ce6bb40.tar.gz unit-12a0d259a50fd6feef46aeffa0e46e193ce6bb40.tar.bz2 |
Docs: special handling for empty "date" and "time" XML attributes.
Diffstat (limited to '')
-rw-r--r-- | docs/changes.xslt | 47 |
1 files changed, 37 insertions, 10 deletions
diff --git a/docs/changes.xslt b/docs/changes.xslt index 032d5c37..08f2f800 100644 --- a/docs/changes.xslt +++ b/docs/changes.xslt @@ -6,6 +6,8 @@ <xsl:param select="'generic'" name="format"/> <xsl:param select="'unit'" name="pkgname"/> <xsl:param select="'change_log_conf.xml'" name="configuration"/> +<xsl:param name="curdate"/> +<xsl:param name="curtime"/> <xsl:variable select="document($configuration)/configuration" name="conf"/> @@ -59,8 +61,10 @@ <xsl:template match="changes"> - <xsl:variable name="pday"> <xsl:call-template name="padded_day"><xsl:with-param select="@date" name="date"/></xsl:call-template></xsl:variable> - <xsl:variable name="dow"> <xsl:call-template name="day_of_week"><xsl:with-param select="@date" name="date"/></xsl:call-template></xsl:variable> + <xsl:variable name="date_"> <xsl:call-template name="getdate"><xsl:with-param select="@date" name="date"/><xsl:with-param select="$curdate" name="curdate"/></xsl:call-template></xsl:variable> + <xsl:variable name="time_"> <xsl:call-template name="gettime"><xsl:with-param select="@time" name="time"/><xsl:with-param select="$curtime" name="curtime"/></xsl:call-template></xsl:variable> + <xsl:variable name="pday"> <xsl:call-template name="padded_day"><xsl:with-param select="$date_" name="date"/></xsl:call-template></xsl:variable> + <xsl:variable name="dow"> <xsl:call-template name="day_of_week"><xsl:with-param select="$date_" name="date"/></xsl:call-template></xsl:variable> <xsl:variable name="apply"> <xsl:call-template name="string_in_list"><xsl:with-param select="@apply" name="list"/><xsl:with-param select="$pkgname" name="string"/></xsl:call-template></xsl:variable> <xsl:variable name="pkgname_"> <xsl:call-template name="beautify"><xsl:with-param select="$pkgname" name="pkgname"/></xsl:call-template></xsl:variable> @@ -78,17 +82,16 @@ ' '), 1, $conf/changes/length)"/> - <xsl:value-of select="substring(@date, 9, 2)"/> - <xsl:value-of select="$conf/changes/month[number(substring(current()/@date, - 6, 2))]"/> - <xsl:value-of select="substring(@date, 1, 4)"/> + <xsl:value-of select="substring($date_, 9, 2)"/> + <xsl:value-of select="$conf/changes/month[number(substring($date_, 6, 2))]"/> + <xsl:value-of select="substring($date_, 1, 4)"/> </xsl:if> <xsl:if test="$format='rpm'"> <xsl:value-of select="concat('* ', $conf/changes/day[number($dow)], - $conf/changes/month[number(substring(current()/@date, 6, 2))], + $conf/changes/month[number(substring($date_, 6, 2))], $pday, ' ', - substring(@date, 1, 4), ' ', @packager, ' - ', + substring($date_, 1, 4), ' ', @packager, ' - ', @ver, '-', @rev, '%{?dist}.ngx')"/> </xsl:if> @@ -109,8 +112,8 @@ <xsl:value-of select="concat(' -- ', @packager, ' ', $conf/changes/day[number($dow)], ', ', $pday, - $conf/changes/month[number(substring(current()/@date, 6, 2))], - substring(@date, 1, 4), ' ', @time)"/> + $conf/changes/month[number(substring($date_, 6, 2))], + substring($date_, 1, 4), ' ', $time_)"/> <xsl:text> </xsl:text> <xsl:text> </xsl:text> @@ -246,6 +249,30 @@ </xsl:template> +<xsl:template name="getdate"><xsl:param name="date"/><xsl:param name="curdate"/> + <xsl:choose> + <xsl:when test="$date=''"> + <xsl:value-of select="$curdate"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$date"/> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + + +<xsl:template name="gettime"><xsl:param name="time"/><xsl:param name="curtime"/> + <xsl:choose> + <xsl:when test="$time=''"> + <xsl:value-of select="$curtime"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$time"/> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + + <xsl:template match="at">@</xsl:template> <xsl:template match="br"> <xsl:value-of select="$br"/> </xsl:template> <xsl:template match="nobr"> <xsl:value-of select="translate(., ' ', ' ')"/> </xsl:template> |