xref: /unit/docs/changes.xslt (revision 1734:3b4f1cc3117f)
1369Sdefan@nginx.com<?xml version="1.0" encoding="utf-8"?>
2369Sdefan@nginx.com<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
3369Sdefan@nginx.com
4369Sdefan@nginx.com<xsl:output method="text"/>
5369Sdefan@nginx.com
6369Sdefan@nginx.com<xsl:param select="'generic'" name="format"/>
7369Sdefan@nginx.com<xsl:param select="'unit'" name="pkgname"/>
8369Sdefan@nginx.com<xsl:param select="'change_log_conf.xml'" name="configuration"/>
9*1734Sdefan@nginx.com<xsl:param name="curdate"/>
10*1734Sdefan@nginx.com<xsl:param name="curtime"/>
11369Sdefan@nginx.com
12369Sdefan@nginx.com<xsl:variable select="document($configuration)/configuration" name="conf"/>
13369Sdefan@nginx.com
14369Sdefan@nginx.com<xsl:variable name="start">
15369Sdefan@nginx.com    <xsl:choose>
16369Sdefan@nginx.com        <xsl:when test="$format='rpm'">
17369Sdefan@nginx.com            <xsl:value-of select="$conf/rpm/start"/>
18369Sdefan@nginx.com        </xsl:when>
19369Sdefan@nginx.com        <xsl:when test="$format='deb'">
20369Sdefan@nginx.com            <xsl:value-of select="$conf/deb/start"/>
21369Sdefan@nginx.com        </xsl:when>
22369Sdefan@nginx.com        <xsl:when test="$format='generic'">
23369Sdefan@nginx.com            <xsl:value-of select="$conf/generic/start"/>
24369Sdefan@nginx.com        </xsl:when>
25369Sdefan@nginx.com    </xsl:choose>
26369Sdefan@nginx.com</xsl:variable>
27369Sdefan@nginx.com
28369Sdefan@nginx.com<xsl:variable name="indent">
29369Sdefan@nginx.com    <xsl:choose>
30369Sdefan@nginx.com        <xsl:when test="$format='rpm'">
31369Sdefan@nginx.com            <xsl:value-of select="$conf/rpm/indent"/>
32369Sdefan@nginx.com        </xsl:when>
33369Sdefan@nginx.com        <xsl:when test="$format='deb'">
34369Sdefan@nginx.com            <xsl:value-of select="$conf/deb/indent"/>
35369Sdefan@nginx.com        </xsl:when>
36369Sdefan@nginx.com        <xsl:when test="$format='generic'">
37369Sdefan@nginx.com            <xsl:value-of select="$conf/generic/indent"/>
38369Sdefan@nginx.com        </xsl:when>
39369Sdefan@nginx.com    </xsl:choose>
40369Sdefan@nginx.com</xsl:variable>
41369Sdefan@nginx.com
42369Sdefan@nginx.com<xsl:variable name="max">
43369Sdefan@nginx.com    <xsl:choose>
44369Sdefan@nginx.com        <xsl:when test="$format='rpm'">
45369Sdefan@nginx.com            <xsl:value-of select="$conf/rpm/length"/>
46369Sdefan@nginx.com        </xsl:when>
47369Sdefan@nginx.com        <xsl:when test="$format='deb'">
48369Sdefan@nginx.com            <xsl:value-of select="$conf/deb/length"/>
49369Sdefan@nginx.com        </xsl:when>
50369Sdefan@nginx.com        <xsl:when test="$format='generic'">
51369Sdefan@nginx.com            <xsl:value-of select="$conf/generic/length"/>
52369Sdefan@nginx.com        </xsl:when>
53369Sdefan@nginx.com    </xsl:choose>
54369Sdefan@nginx.com</xsl:variable>
55369Sdefan@nginx.com
56369Sdefan@nginx.com<xsl:variable name="br">&lt;br&gt;</xsl:variable>
57369Sdefan@nginx.com
58369Sdefan@nginx.com
59369Sdefan@nginx.com<xsl:template match="/"> <xsl:apply-templates select="change_log"/> </xsl:template>
60369Sdefan@nginx.com<xsl:template match="change_log"> <xsl:apply-templates select="changes"/> </xsl:template>
61369Sdefan@nginx.com
62369Sdefan@nginx.com
63369Sdefan@nginx.com<xsl:template match="changes">
64*1734Sdefan@nginx.com    <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>
65*1734Sdefan@nginx.com    <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>
66*1734Sdefan@nginx.com    <xsl:variable name="pday"> <xsl:call-template name="padded_day"><xsl:with-param select="$date_" name="date"/></xsl:call-template></xsl:variable>
67*1734Sdefan@nginx.com    <xsl:variable name="dow"> <xsl:call-template name="day_of_week"><xsl:with-param select="$date_" name="date"/></xsl:call-template></xsl:variable>
68369Sdefan@nginx.com    <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>
69369Sdefan@nginx.com    <xsl:variable name="pkgname_"> <xsl:call-template name="beautify"><xsl:with-param select="$pkgname" name="pkgname"/></xsl:call-template></xsl:variable>
70369Sdefan@nginx.com
71794Sdefan@nginx.com    <xsl:choose>
72794Sdefan@nginx.com    <xsl:when test="$pkgname='unit' and $format='generic' and @rev!=1"/>
73794Sdefan@nginx.com    <xsl:otherwise>
74369Sdefan@nginx.com    <xsl:if test="$apply=$pkgname">
75369Sdefan@nginx.com
76369Sdefan@nginx.com    <xsl:if test="$format='generic'">
77369Sdefan@nginx.com        <xsl:text>&#10;</xsl:text>
78369Sdefan@nginx.com
79369Sdefan@nginx.com        <xsl:value-of select="substring(concat($conf/changes/title,
80369Sdefan@nginx.com                           $pkgname_,
81369Sdefan@nginx.com                           ' ', @ver,
82369Sdefan@nginx.com                           '                                                    '),
83369Sdefan@nginx.com                    1, $conf/changes/length)"/>
84369Sdefan@nginx.com
85*1734Sdefan@nginx.com        <xsl:value-of select="substring($date_, 9, 2)"/>
86*1734Sdefan@nginx.com        <xsl:value-of select="$conf/changes/month[number(substring($date_, 6, 2))]"/>
87*1734Sdefan@nginx.com        <xsl:value-of select="substring($date_, 1, 4)"/>
88369Sdefan@nginx.com    </xsl:if>
89369Sdefan@nginx.com
90369Sdefan@nginx.com    <xsl:if test="$format='rpm'">
91369Sdefan@nginx.com        <xsl:value-of select="concat('* ', $conf/changes/day[number($dow)],
92*1734Sdefan@nginx.com                 $conf/changes/month[number(substring($date_, 6, 2))],
93369Sdefan@nginx.com                 $pday, ' ',
94*1734Sdefan@nginx.com                 substring($date_, 1, 4), ' ', @packager, ' - ',
95369Sdefan@nginx.com                 @ver, '-', @rev, '%{?dist}.ngx')"/>
96369Sdefan@nginx.com    </xsl:if>
97369Sdefan@nginx.com
98369Sdefan@nginx.com    <xsl:if test="$format='deb'">
99369Sdefan@nginx.com        <xsl:value-of select="concat($pkgname, ' (', @ver, '-', @rev,
100369Sdefan@nginx.com                 '~%%CODENAME%%) %%CODENAME%%; urgency=low')"/>
101369Sdefan@nginx.com
102369Sdefan@nginx.com        <xsl:text>&#10;</xsl:text>
103369Sdefan@nginx.com    </xsl:if>
104369Sdefan@nginx.com
105369Sdefan@nginx.com    <xsl:text>&#10;</xsl:text>
106369Sdefan@nginx.com
107369Sdefan@nginx.com    <xsl:apply-templates select="change"/>
108369Sdefan@nginx.com
109369Sdefan@nginx.com    <xsl:text>&#10;</xsl:text>
110369Sdefan@nginx.com
111369Sdefan@nginx.com    <xsl:if test="$format='deb'">
112369Sdefan@nginx.com        <xsl:value-of select="concat(' -- ', @packager, '  ',
113369Sdefan@nginx.com                 $conf/changes/day[number($dow)], ', ',
114369Sdefan@nginx.com                 $pday,
115*1734Sdefan@nginx.com                 $conf/changes/month[number(substring($date_, 6, 2))],
116*1734Sdefan@nginx.com                 substring($date_, 1, 4), ' ', $time_)"/>
117369Sdefan@nginx.com
118369Sdefan@nginx.com        <xsl:text>&#10;</xsl:text>
119369Sdefan@nginx.com        <xsl:text>&#10;</xsl:text>
120369Sdefan@nginx.com    </xsl:if>
121369Sdefan@nginx.com    </xsl:if>
122794Sdefan@nginx.com    </xsl:otherwise>
123794Sdefan@nginx.com    </xsl:choose>
124369Sdefan@nginx.com</xsl:template>
125369Sdefan@nginx.com
126369Sdefan@nginx.com
127369Sdefan@nginx.com<xsl:template match="change">
128369Sdefan@nginx.com    <xsl:variable select="$conf/changes/*[local-name(.)=current()/@type]" name="prefix"/>
129369Sdefan@nginx.com
130369Sdefan@nginx.com    <xsl:variable name="postfix"> <xsl:if test="$prefix"> <xsl:text>: </xsl:text> </xsl:if> </xsl:variable>
131369Sdefan@nginx.com
132369Sdefan@nginx.com    <xsl:apply-templates select="para"><xsl:with-param select="concat($start, $prefix, $postfix)" name="prefix"/></xsl:apply-templates>
133369Sdefan@nginx.com</xsl:template>
134369Sdefan@nginx.com
135369Sdefan@nginx.com
136369Sdefan@nginx.com<xsl:template name="para" match="para"><xsl:param name="prefix"/>
137369Sdefan@nginx.com    <xsl:variable name="text"> <xsl:apply-templates/> </xsl:variable>
138369Sdefan@nginx.com
139369Sdefan@nginx.com    <xsl:if test="$format='generic'">
140369Sdefan@nginx.com        <xsl:text>&#10;</xsl:text>
141369Sdefan@nginx.com    </xsl:if>
142369Sdefan@nginx.com
143369Sdefan@nginx.com    <xsl:call-template name="wrap"><xsl:with-param select="normalize-space($text)" name="text"/><xsl:with-param name="prefix"> <xsl:choose><xsl:when test="position() = 1"> <xsl:value-of select="$prefix"/> </xsl:when><xsl:otherwise> <xsl:value-of select="$indent"/> </xsl:otherwise></xsl:choose> </xsl:with-param></xsl:call-template></xsl:template>
144369Sdefan@nginx.com
145369Sdefan@nginx.com
146369Sdefan@nginx.com<xsl:template name="wrap"><xsl:param name="text"/><xsl:param name="prefix"/>
147369Sdefan@nginx.com    <xsl:if test="$text">
148369Sdefan@nginx.com        <xsl:variable name="offset">
149369Sdefan@nginx.com            <xsl:choose>
150369Sdefan@nginx.com                <xsl:when test="starts-with($text, concat($br, ' '))">
151369Sdefan@nginx.com                    <xsl:value-of select="string-length($br) + 2"/>
152369Sdefan@nginx.com                </xsl:when>
153369Sdefan@nginx.com                <xsl:when test="starts-with($text, $br)">
154369Sdefan@nginx.com                    <xsl:value-of select="string-length($br) + 1"/>
155369Sdefan@nginx.com                </xsl:when>
156369Sdefan@nginx.com                <xsl:otherwise>
157369Sdefan@nginx.com                    1
158369Sdefan@nginx.com                </xsl:otherwise>
159369Sdefan@nginx.com            </xsl:choose>
160369Sdefan@nginx.com        </xsl:variable>
161369Sdefan@nginx.com
162369Sdefan@nginx.com        <xsl:variable name="length">
163369Sdefan@nginx.com            <xsl:call-template name="length"><xsl:with-param select="substring($text, $offset)" name="text"/><xsl:with-param select="string-length($prefix)" name="prefix"/><xsl:with-param select="$max" name="length"/></xsl:call-template></xsl:variable>
164369Sdefan@nginx.com
165369Sdefan@nginx.com        <xsl:value-of select="$prefix"/>
166369Sdefan@nginx.com
167369Sdefan@nginx.com        <xsl:value-of select="normalize-space(translate(substring($text, $offset, $length),
168369Sdefan@nginx.com                                    '&#xA0;', ' '))"/>
169369Sdefan@nginx.com
170369Sdefan@nginx.com        <xsl:text>&#10;</xsl:text>
171369Sdefan@nginx.com
172369Sdefan@nginx.com        <xsl:call-template name="wrap"><xsl:with-param select="substring($text, $length + $offset)" name="text"/><xsl:with-param select="$indent" name="prefix"/></xsl:call-template></xsl:if>
173369Sdefan@nginx.com</xsl:template>
174369Sdefan@nginx.com
175369Sdefan@nginx.com
176369Sdefan@nginx.com<xsl:template name="length"><xsl:param name="text"/><xsl:param name="prefix"/><xsl:param name="length"/>
177369Sdefan@nginx.com    <xsl:variable select="substring-before(substring($text, 1,
178369Sdefan@nginx.com                                    $length - $prefix + string-length($br)),
179369Sdefan@nginx.com                                    $br)" name="break"/>
180369Sdefan@nginx.com
181369Sdefan@nginx.com    <xsl:choose>
182369Sdefan@nginx.com        <xsl:when test="$break"> <xsl:value-of select="string-length($break)"/> </xsl:when>
183369Sdefan@nginx.com
184369Sdefan@nginx.com        <xsl:when test="$length = 0"> <xsl:value-of select="$max - $prefix"/> </xsl:when>
185369Sdefan@nginx.com
186369Sdefan@nginx.com        <xsl:when test="string-length($text) + $prefix &lt;= $length">
187369Sdefan@nginx.com            <xsl:value-of select="$length - $prefix"/>
188369Sdefan@nginx.com        </xsl:when>
189369Sdefan@nginx.com
190369Sdefan@nginx.com        <xsl:when test="substring($text, $length - $prefix + 1, 1) = ' '">
191369Sdefan@nginx.com            <xsl:value-of select="$length - $prefix + 1"/>
192369Sdefan@nginx.com        </xsl:when>
193369Sdefan@nginx.com
194369Sdefan@nginx.com        <xsl:otherwise>
195369Sdefan@nginx.com            <xsl:call-template name="length"><xsl:with-param select="$text" name="text"/><xsl:with-param select="$prefix" name="prefix"/><xsl:with-param select="$length - 1" name="length"/></xsl:call-template></xsl:otherwise>
196369Sdefan@nginx.com    </xsl:choose>
197369Sdefan@nginx.com</xsl:template>
198369Sdefan@nginx.com
199369Sdefan@nginx.com
200369Sdefan@nginx.com<xsl:template name="day_of_week"><xsl:param name="date"/>
201369Sdefan@nginx.com    <xsl:param select="substring-before($date, '-')" name="year"/>
202369Sdefan@nginx.com    <xsl:param select="substring-before(substring-after($date, '-'), '-')" name="month"/>
203369Sdefan@nginx.com    <xsl:param select="substring-after(substring-after($date, '-'), '-')" name="day"/>
204369Sdefan@nginx.com
205369Sdefan@nginx.com    <xsl:variable select="floor((14 - $month) div 12)" name="a"/>
206369Sdefan@nginx.com
207369Sdefan@nginx.com    <xsl:variable select="$year - $a" name="y"/>
208369Sdefan@nginx.com
209369Sdefan@nginx.com    <xsl:variable select="$month + 12 * $a - 2" name="m"/>
210369Sdefan@nginx.com
211369Sdefan@nginx.com    <xsl:value-of select="($day + $y + floor($y div 4) - floor($y div 100)
212369Sdefan@nginx.com    + floor($y div 400) + floor((31 * $m) div 12)) mod 7 + 1"/>
213369Sdefan@nginx.com</xsl:template>
214369Sdefan@nginx.com
215369Sdefan@nginx.com
216369Sdefan@nginx.com<xsl:template name="padded_day"><xsl:param name="date"/>
217369Sdefan@nginx.com    <xsl:value-of select="substring(concat('  ', format-number(substring($date, 9, 2), '##')),
218369Sdefan@nginx.com           1 + string-length(format-number(substring($date, 9, 2), '##')))"/>
219369Sdefan@nginx.com</xsl:template>
220369Sdefan@nginx.com
221369Sdefan@nginx.com
222369Sdefan@nginx.com<xsl:template name="string_in_list"><xsl:param name="list"/><xsl:param name="string"/>
223369Sdefan@nginx.com    <xsl:choose>
224547Sdefan@nginx.com        <xsl:when test="contains($list, ' ')">
225547Sdefan@nginx.com            <xsl:variable select="substring-before($list, ' ')" name="str"/>
226547Sdefan@nginx.com            <xsl:choose>
227547Sdefan@nginx.com                <xsl:when test="$str=$string">
228547Sdefan@nginx.com                    <xsl:value-of select="$string"/>
229547Sdefan@nginx.com                </xsl:when>
230547Sdefan@nginx.com                <xsl:otherwise>
231547Sdefan@nginx.com                    <xsl:call-template name="string_in_list"><xsl:with-param select="substring-after($list, ' ')" name="list"/><xsl:with-param select="$string" name="string"/></xsl:call-template></xsl:otherwise>
232547Sdefan@nginx.com            </xsl:choose>
233547Sdefan@nginx.com        </xsl:when>
234369Sdefan@nginx.com        <xsl:otherwise>
235369Sdefan@nginx.com            <xsl:if test="$list=$string"> <xsl:value-of select="$string"/> </xsl:if>
236369Sdefan@nginx.com            <xsl:if test="$list='*'"> <xsl:value-of select="$string"/> </xsl:if>
237369Sdefan@nginx.com        </xsl:otherwise>
238369Sdefan@nginx.com    </xsl:choose>
239369Sdefan@nginx.com</xsl:template>
240369Sdefan@nginx.com
241369Sdefan@nginx.com
242369Sdefan@nginx.com<xsl:template name="beautify"><xsl:param name="pkgname"/>
243369Sdefan@nginx.com    <xsl:choose>
244369Sdefan@nginx.com        <xsl:when test="$pkgname='unit'">Unit</xsl:when>
245369Sdefan@nginx.com        <xsl:otherwise>
246369Sdefan@nginx.com            <xsl:value-of select="$pkgname"/>
247369Sdefan@nginx.com        </xsl:otherwise>
248369Sdefan@nginx.com    </xsl:choose>
249369Sdefan@nginx.com</xsl:template>
250369Sdefan@nginx.com
251369Sdefan@nginx.com
252*1734Sdefan@nginx.com<xsl:template name="getdate"><xsl:param name="date"/><xsl:param name="curdate"/>
253*1734Sdefan@nginx.com    <xsl:choose>
254*1734Sdefan@nginx.com        <xsl:when test="$date=''">
255*1734Sdefan@nginx.com            <xsl:value-of select="$curdate"/>
256*1734Sdefan@nginx.com        </xsl:when>
257*1734Sdefan@nginx.com        <xsl:otherwise>
258*1734Sdefan@nginx.com            <xsl:value-of select="$date"/>
259*1734Sdefan@nginx.com        </xsl:otherwise>
260*1734Sdefan@nginx.com    </xsl:choose>
261*1734Sdefan@nginx.com</xsl:template>
262*1734Sdefan@nginx.com
263*1734Sdefan@nginx.com
264*1734Sdefan@nginx.com<xsl:template name="gettime"><xsl:param name="time"/><xsl:param name="curtime"/>
265*1734Sdefan@nginx.com    <xsl:choose>
266*1734Sdefan@nginx.com        <xsl:when test="$time=''">
267*1734Sdefan@nginx.com            <xsl:value-of select="$curtime"/>
268*1734Sdefan@nginx.com        </xsl:when>
269*1734Sdefan@nginx.com        <xsl:otherwise>
270*1734Sdefan@nginx.com            <xsl:value-of select="$time"/>
271*1734Sdefan@nginx.com        </xsl:otherwise>
272*1734Sdefan@nginx.com    </xsl:choose>
273*1734Sdefan@nginx.com</xsl:template>
274*1734Sdefan@nginx.com
275*1734Sdefan@nginx.com
276369Sdefan@nginx.com<xsl:template match="at">@</xsl:template>
277369Sdefan@nginx.com<xsl:template match="br"> <xsl:value-of select="$br"/> </xsl:template>
278369Sdefan@nginx.com<xsl:template match="nobr"> <xsl:value-of select="translate(., ' ', '&#xA0;')"/> </xsl:template>
279369Sdefan@nginx.com
280369Sdefan@nginx.com
281369Sdefan@nginx.com</xsl:stylesheet>
282