/[vps]/baselayout-vserver/trunk/src/core/scripts/svn2cl.xsl
Gentoo

Diff of /baselayout-vserver/trunk/src/core/scripts/svn2cl.xsl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 235 Revision 236
3<!-- 3<!--
4 4
5 svn2cl.xsl - xslt stylesheet for converting svn log to a normal 5 svn2cl.xsl - xslt stylesheet for converting svn log to a normal
6 changelog 6 changelog
7 7
8 Usage (replace ++ with two minus signs): 8 Usage (replace ++ with two minus signs which aren't allowed
9 inside xml comments):
9 svn ++verbose ++xml log | \ 10 svn ++verbose ++xml log | \
10 xsltproc ++stringparam strip-prefix `basename $(pwd)` \ 11 xsltproc ++stringparam strip-prefix `basename $(pwd)` \
11 ++stringparam linelen 75 \ 12 ++stringparam linelen 75 \
12 ++stringparam groupbyday yes \ 13 ++stringparam groupbyday yes \
13 ++stringparam include-rev yes \ 14 ++stringparam include-rev yes \
46 47
47--> 48-->
48 49
49<!DOCTYPE page [ 50<!DOCTYPE page [
50 <!ENTITY tab "&#9;"> 51 <!ENTITY tab "&#9;">
51 <!ENTITY newl "&#13;"> 52 <!ENTITY newl "&#10;">
52 <!ENTITY space "&#32;"> 53 <!ENTITY space "&#32;">
53]> 54]>
54 55
55<!--
56 TODO
57 - make external lookups of author names possible
58 - find a place for revision numbers
59 - mark deleted files as such
60 - combine paths
61 - make path formatting nicer
62-->
63
64<xsl:stylesheet 56<xsl:stylesheet
65 version="1.0" 57 version="1.0"
66 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 58 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
67 xmlns="http://www.w3.org/1999/xhtml">
68 59
69 <xsl:output 60 <xsl:output
70 method="text" 61 method="text"
71 encoding="iso-8859-15" 62 encoding="utf-8"
72 media-type="text/plain" 63 media-type="text/plain"
73 omit-xml-declaration="yes" 64 omit-xml-declaration="yes"
74 standalone="yes" 65 standalone="yes"
75 indent="no" /> 66 indent="no" />
76 67
95 </xsl:template> 86 </xsl:template>
96 87
97 <!-- format one entry from the log --> 88 <!-- format one entry from the log -->
98 <xsl:template match="logentry"> 89 <xsl:template match="logentry">
99 <!-- save log entry number --> 90 <!-- save log entry number -->
100 <xsl:variable name="pos" select="position()"/> 91 <xsl:variable name="pos" select="position()" />
101 <!-- fetch previous entry's date --> 92 <!-- fetch previous entry's date -->
102 <xsl:variable name="prevdate"> 93 <xsl:variable name="prevdate">
103 <xsl:apply-templates select="../logentry[position()=(($pos)-1)]/date"/> 94 <xsl:apply-templates select="../logentry[position()=(($pos)-1)]/date" />
104 </xsl:variable> 95 </xsl:variable>
105 <!-- fetch previous entry's author --> 96 <!-- fetch previous entry's author -->
106 <xsl:variable name="prevauthor"> 97 <xsl:variable name="prevauthor">
107 <xsl:apply-templates select="../logentry[position()=(($pos)-1)]/author"/> 98 <xsl:apply-templates select="../logentry[position()=(($pos)-1)]/author" />
108 </xsl:variable> 99 </xsl:variable>
109 <!-- fetch this entry's date --> 100 <!-- fetch this entry's date -->
110 <xsl:variable name="date"> 101 <xsl:variable name="date">
111 <xsl:apply-templates select="date" /> 102 <xsl:apply-templates select="date" />
112 </xsl:variable> 103 </xsl:variable>
130 <xsl:text>&newl;&newl;</xsl:text> 121 <xsl:text>&newl;&newl;</xsl:text>
131 </xsl:if> 122 </xsl:if>
132 <!-- get paths string --> 123 <!-- get paths string -->
133 <xsl:variable name="paths"> 124 <xsl:variable name="paths">
134 <xsl:apply-templates select="paths" /> 125 <xsl:apply-templates select="paths" />
126 <xsl:text>:&space;</xsl:text>
135 </xsl:variable> 127 </xsl:variable>
136 <!-- get revision number --> 128 <!-- get revision number -->
137 <xsl:variable name="rev"> 129 <xsl:variable name="rev">
138 <xsl:if test="$include-rev='yes'"> 130 <xsl:if test="$include-rev='yes'">
139 <xsl:text>[r</xsl:text> 131 <xsl:text>[r</xsl:text>
140 <xsl:value-of select="@revision"/> 132 <xsl:value-of select="@revision" />
141 <xsl:text>]&space;</xsl:text> 133 <xsl:text>]&space;</xsl:text>
142 </xsl:if> 134 </xsl:if>
135 </xsl:variable>
136 <!-- trim trailing newlines -->
137 <xsl:variable name="msg">
138 <xsl:call-template name="trim-newln">
139 <xsl:with-param name="txt" select="msg" />
140 </xsl:call-template>
143 </xsl:variable> 141 </xsl:variable>
144 <!-- first line is indented (other indents are done in wrap template) --> 142 <!-- first line is indented (other indents are done in wrap template) -->
145 <xsl:text>&tab;*&space;</xsl:text> 143 <xsl:text>&tab;*&space;</xsl:text>
146 <!-- print the paths and message nicely wrapped --> 144 <!-- print the paths and message nicely wrapped -->
147 <xsl:call-template name="wrap"> 145 <xsl:call-template name="wrap">
148 <xsl:with-param name="txt" select="concat($rev,$paths,normalize-space(msg))" /> 146 <xsl:with-param name="txt" select="concat($rev,$paths,$msg)" />
149 </xsl:call-template> 147 </xsl:call-template>
150 </xsl:template> 148 </xsl:template>
151 149
152 <!-- format date --> 150 <!-- format date -->
153 <xsl:template match="date"> 151 <xsl:template match="date">
173 <!-- unless we are the first entry, add a comma --> 171 <!-- unless we are the first entry, add a comma -->
174 <xsl:if test="not(position()=1)"> 172 <xsl:if test="not(position()=1)">
175 <xsl:text>,&space;</xsl:text> 173 <xsl:text>,&space;</xsl:text>
176 </xsl:if> 174 </xsl:if>
177 <!-- print the path name --> 175 <!-- print the path name -->
178 <xsl:apply-templates select="."/> 176 <xsl:apply-templates select="." />
179 </xsl:for-each> 177 </xsl:for-each>
180 <!-- end the list with a colon -->
181 <xsl:text>:&space;</xsl:text>
182 </xsl:template> 178 </xsl:template>
183 179
184 <!-- transform path to something printable --> 180 <!-- transform path to something printable -->
185 <xsl:template match="path"> 181 <xsl:template match="path">
186 <!-- fetch the pathname --> 182 <!-- fetch the pathname -->
243 239
244 <!-- string-wrapping template --> 240 <!-- string-wrapping template -->
245 <xsl:template name="wrap"> 241 <xsl:template name="wrap">
246 <xsl:param name="txt" /> 242 <xsl:param name="txt" />
247 <xsl:choose> 243 <xsl:choose>
244 <xsl:when test="contains($txt,'&#xa;')">
245 <!-- text contains newlines, do the first line -->
246 <xsl:call-template name="wrap">
247 <xsl:with-param name="txt" select="substring-before($txt,'&#xa;')" />
248 </xsl:call-template>
249 <!-- print tab -->
250 <xsl:text>&tab;&space;&space;</xsl:text>
251 <!-- wrap the rest of the text -->
252 <xsl:call-template name="wrap">
253 <xsl:with-param name="txt" select="substring-after($txt,'&#xa;')" />
254 </xsl:call-template>
255 </xsl:when>
248 <xsl:when test="(string-length($txt) &lt; (($linelen)-9)) or not(contains($txt,' '))"> 256 <xsl:when test="(string-length($txt) &lt; (($linelen)-9)) or not(contains($txt,' '))">
249 <!-- this is easy, nothing to do --> 257 <!-- this is easy, nothing to do -->
250 <xsl:value-of select="$txt" /> 258 <xsl:value-of select="$txt" />
251 <!-- add newline --> 259 <!-- add newline -->
252 <xsl:text>&newl;</xsl:text> 260 <xsl:text>&newl;</xsl:text>
269 <!-- print newline and tab --> 277 <!-- print newline and tab -->
270 <xsl:value-of select="$line" /> 278 <xsl:value-of select="$line" />
271 <xsl:text>&newl;&tab;&space;&space;</xsl:text> 279 <xsl:text>&newl;&tab;&space;&space;</xsl:text>
272 <!-- wrap the rest of the text --> 280 <!-- wrap the rest of the text -->
273 <xsl:call-template name="wrap"> 281 <xsl:call-template name="wrap">
274 <xsl:with-param name="txt" select="normalize-space(substring($txt,string-length($line)+1))" /> 282 <xsl:with-param name="txt" select="substring($txt,string-length($line)+1)" />
275 </xsl:call-template> 283 </xsl:call-template>
276 </xsl:otherwise> 284 </xsl:otherwise>
277 </xsl:choose> 285 </xsl:choose>
278 </xsl:template> 286 </xsl:template>
279 287
280 <!-- template to trim line to contain space as last char --> 288 <!-- template to trim line to contain space as last char -->
281 <xsl:template name="find-line"> 289 <xsl:template name="find-line">
282 <xsl:param name="txt" /> 290 <xsl:param name="txt" />
283 <xsl:choose> 291 <xsl:choose>
284 <xsl:when test="substring($txt,string-length($txt),1) = ' '"> 292 <xsl:when test="substring($txt,string-length($txt),1) = ' '">
285 <xsl:value-of select="normalize-space($txt)" /> 293 <xsl:value-of select="$txt" />
286 </xsl:when> 294 </xsl:when>
287 <xsl:otherwise> 295 <xsl:otherwise>
288 <xsl:call-template name="find-line"> 296 <xsl:call-template name="find-line">
289 <xsl:with-param name="txt" select="substring($txt,1,string-length($txt)-1)" /> 297 <xsl:with-param name="txt" select="substring($txt,1,string-length($txt)-1)" />
290 </xsl:call-template> 298 </xsl:call-template>
291 </xsl:otherwise> 299 </xsl:otherwise>
292 </xsl:choose> 300 </xsl:choose>
293 </xsl:template> 301 </xsl:template>
294 302
303 <!-- template to trim trailing and starting newlines -->
304 <xsl:template name="trim-newln">
305 <xsl:param name="txt" />
306 <xsl:choose>
307 <!-- find starting newlines -->
308 <xsl:when test="substring($txt,1,1) = '&#xa;'">
309 <xsl:call-template name="trim-newln">
310 <xsl:with-param name="txt" select="substring($txt,2)" />
311 </xsl:call-template>
312 </xsl:when>
313 <!-- find trailing newlines -->
314 <xsl:when test="substring($txt,string-length($txt),1) = '&#xa;'">
315 <xsl:call-template name="trim-newln">
316 <xsl:with-param name="txt" select="substring($txt,1,string-length($txt)-1)" />
317 </xsl:call-template>
318 </xsl:when>
319 <!-- no newlines found, we're done -->
320 <xsl:otherwise>
321 <xsl:value-of select="$txt" />
322 </xsl:otherwise>
323 </xsl:choose>
324 </xsl:template>
325
295</xsl:stylesheet> 326</xsl:stylesheet>

Legend:
Removed from v.235  
changed lines
  Added in v.236

  ViewVC Help
Powered by ViewVC 1.1.20