1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:util="urn:xslt:functions:util" xmlns:func="http://exslt.org/functions" xmlns:str="http://exslt.org/strings" extension-element-prefixes="func str">
<xsl:output method="text"/>
<func:function name="util:maximize">
<xsl:param name="string"/>
<xsl:param name="line-length"/>
<func:result>
<xsl:variable name="tmp" select="string-length(substring-before($string,' '))"/>
<xsl:choose>
<xsl:when test="($tmp > $line-length) or (not(contains($string, ' ')))">0</xsl:when>
<xsl:when test="(substring($string,$line-length,1) = ' ')">
<xsl:value-of select="$line-length"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="util:maximize(substring-after($string, ' '), $line-length - $tmp - 1) + 1 + $tmp"/>
</xsl:otherwise>
</xsl:choose>
</func:result>
</func:function>
<func:function name="util:format">
<xsl:param name="string"/>
<xsl:param name="indent" select="2"/>
<xsl:param name="line-length" select="76"/>
<func:result>
<xsl:choose>
<xsl:when test="contains($string,'
') or contains($string,'
')">
<xsl:for-each select="str:tokenize($string,'

')">
<xsl:value-of select="util:format(., $indent, $line-length)"/>
</xsl:for-each>
</xsl:when>
<xsl:when test="string-length($string) > $line-length">
<xsl:variable name="tmp" select="util:maximize($string, $line-length)"/>
<xsl:value-of select="str:padding($indent,' ')"/>
<xsl:value-of select="substring($string, 1, $tmp)"/>
<xsl:text>
</xsl:text>
<xsl:value-of select="util:format(substring($string, $tmp + 1))"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="str:padding($indent,' ')"/>
<xsl:value-of select="$string"/>
<xsl:text>
</xsl:text>
</xsl:otherwise>
</xsl:choose>
</func:result>
</func:function>
<func:function name="util:norm">
<xsl:param name="num"/>
<xsl:param name="length" select="4"/>
<xsl:choose>
<xsl:when test="$length > string-length($num)">
<func:result select="concat('0',util:norm($num, $length - 1))"/>
</xsl:when>
<xsl:otherwise>
<func:result select="$num"/>
</xsl:otherwise>
</xsl:choose>
</func:function>
<func:function name="util:extractnum">
<xsl:param name="string"/>
<xsl:choose>
<xsl:when test="$string = ''">
<func:result select="0"/>
</xsl:when>
<xsl:when test="$string <= '9' and $string >= '0'">
<func:result select="$string"/>
</xsl:when>
<xsl:otherwise>
<func:result select="util:extractnum(substring($string,1,string-length($string)-1))"/>
</xsl:otherwise>
</xsl:choose>
</func:function>
<func:function name="util:ver2num">
<xsl:param name="version"/>
<xsl:choose>
<xsl:when test="contains($version,'.')">
<func:result select="concat(util:norm(substring-before($version,'.')), util:ver2num(substring-after($version,'.')))"/>
</xsl:when>
<xsl:when test="$version = number($version)">
<func:result select="concat(util:norm($version), util:norm(0))"/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="tmp" select="util:extractnum($version)"/>
<func:result select="concat(util:norm($tmp),' ', substring($version, string-length($tmp) + 1))"/>
</xsl:otherwise>
</xsl:choose>
</func:function>
<xsl:template match="package">
<xsl:apply-templates select="release">
<xsl:sort order="descending" select="util:ver2num(normalize-space(version))" data-type="text"/>
</xsl:apply-templates>
<xsl:apply-templates select="changelog/release">
<xsl:sort order="descending" select="util:ver2num(normalize-space(version))" data-type="text"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="release">
<xsl:text>Version </xsl:text>
<xsl:value-of select="version"/>
<xsl:text> - </xsl:text>
<xsl:value-of select="date"/>
<xsl:if test="state">
<xsl:text> (</xsl:text>
<xsl:value-of select="state"/>
<xsl:text>)</xsl:text>
</xsl:if>
<xsl:text>
----------------------------------------
Notes:
</xsl:text>
<xsl:value-of select="util:format(notes)"/>
<xsl:text>
</xsl:text>
</xsl:template>
</xsl:stylesheet>
|