Follow-up to r29036: Now that the "mergeinfo" transaction file is no
[svn.git] / contrib / client-side / svn2cl / svn2html.xsl
blob19157da3fd5e10dde4a8ebc7ed3141a878357d45
1 <?xml version="1.0" encoding="utf-8"?>
3 <!--
5 svn2html.xsl - xslt stylesheet for converting svn log to a normal
6 changelog fromatted in html
8 version 0.9
10 Usage (replace ++ with two minus signs):
11 svn ++verbose ++xml log | \
12 xsltproc ++stringparam strip-prefix `basename $(pwd)` \
13 ++stringparam groupbyday yes \
14 ++stringparam authorsfile FILE \
15 ++stringparam title NAME \
16 ++stringparam revision-link NAME \
17 svn2html.xsl - > ChangeLog.html
19 This file is partially based on (and includes) svn2cl.xsl.
21 Copyright (C) 2005, 2006, 2007 Arthur de Jong.
23 Redistribution and use in source and binary forms, with or without
24 modification, are permitted provided that the following conditions
25 are met:
26 1. Redistributions of source code must retain the above copyright
27 notice, this list of conditions and the following disclaimer.
28 2. Redistributions in binary form must reproduce the above copyright
29 notice, this list of conditions and the following disclaimer in
30 the documentation and/or other materials provided with the
31 distribution.
32 3. The name of the author may not be used to endorse or promote
33 products derived from this software without specific prior
34 written permission.
36 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
37 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
38 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
39 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
40 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
41 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
42 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
43 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
44 IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
45 OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
46 IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
48 -->
50 <!DOCTYPE xsl:stylesheet [
51 <!ENTITY newl "&#10;">
52 <!ENTITY space "&#32;">
55 <xsl:stylesheet
56 version="1.0"
57 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
58 xmlns="http://www.w3.org/1999/xhtml">
60 <!-- include default formatting templates from svn2cl.xsl -->
61 <xsl:include href="svn2cl.xsl" />
63 <xsl:output
64 method="xml"
65 encoding="utf-8"
66 media-type="text/html"
67 omit-xml-declaration="no"
68 standalone="yes"
69 indent="yes"
70 doctype-public="-//W3C//DTD XHTML 1.1//EN"
71 doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" />
73 <!-- title of the report -->
74 <xsl:param name="title" select="'ChangeLog'" />
76 <!-- link to use for linking revision numbers -->
77 <xsl:param name="revision-link" select="'#r'" />
79 <!-- match toplevel element -->
80 <xsl:template match="log">
81 <html>
82 <head>
83 <title><xsl:value-of select="string($title)" /></title>
84 <link rel="stylesheet" href="svn2html.css" type="text/css" />
85 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
86 </head>
87 <body>
88 <xsl:if test="$title">
89 <h1><xsl:value-of select="string($title)" /></h1>
90 </xsl:if>
91 <ul class="changelog_entries">
92 <xsl:choose>
93 <xsl:when test="$ignore-message-starting != ''">
94 <!-- only handle logentries with don't contain the string -->
95 <xsl:apply-templates select="logentry[not(starts-with(msg,$ignore-message-starting))]" />
96 </xsl:when>
97 <xsl:otherwise>
98 <xsl:apply-templates select="logentry" />
99 </xsl:otherwise>
100 </xsl:choose>
101 </ul>
102 <p class="changelog_footer">
103 <xsl:text>Generated by </xsl:text><a href="http://ch.tudelft.nl/~arthur/svn2cl/">svn2cl 0.9</a>
104 </p>
105 </body>
106 </html>
107 </xsl:template>
109 <!-- format one entry from the log -->
110 <xsl:template match="logentry">
111 <xsl:choose>
112 <!-- if we're grouping we should omit some headers -->
113 <xsl:when test="$groupbyday='yes'">
114 <!-- save log entry number -->
115 <xsl:variable name="pos" select="position()" />
116 <!-- fetch previous entry's date -->
117 <xsl:variable name="prevdate">
118 <xsl:apply-templates select="../logentry[position()=(($pos)-1)]/date" />
119 </xsl:variable>
120 <!-- fetch previous entry's author -->
121 <xsl:variable name="prevauthor">
122 <xsl:value-of select="normalize-space(../logentry[position()=(($pos)-1)]/author)" />
123 </xsl:variable>
124 <!-- fetch this entry's date -->
125 <xsl:variable name="date">
126 <xsl:apply-templates select="date" />
127 </xsl:variable>
128 <!-- fetch this entry's author -->
129 <xsl:variable name="author">
130 <xsl:value-of select="normalize-space(author)" />
131 </xsl:variable>
132 <!-- check if header is changed -->
133 <xsl:if test="($prevdate!=$date) or ($prevauthor!=$author)">
134 <li class="changelog_entry">
135 <!-- date -->
136 <span class="changelog_date"><xsl:value-of select="$date" /></span>
137 <xsl:text>&space;</xsl:text>
138 <!-- author's name -->
139 <span class="changelog_author"><xsl:apply-templates select="author" /></span>
140 </li>
141 </xsl:if>
142 </xsl:when>
143 <!-- write the log header -->
144 <xsl:otherwise>
145 <li class="changelog_entry">
146 <!-- date -->
147 <span class="changelog_date"><xsl:apply-templates select="date" /></span>
148 <xsl:text>&space;</xsl:text>
149 <!-- author's name -->
150 <span class="changelog_author"><xsl:apply-templates select="author" /></span>
151 </li>
152 </xsl:otherwise>
153 </xsl:choose>
154 <!-- entry -->
155 <li class="changelog_change">
156 <!-- get revision number -->
157 <xsl:variable name="revlink">
158 <xsl:choose>
159 <xsl:when test="contains($revision-link,'##')">
160 <xsl:value-of select="concat(substring-before($revision-link,'##'),@revision,substring-after($revision-link,'##'))" />
161 </xsl:when>
162 <xsl:otherwise>
163 <xsl:value-of select="concat($revision-link,@revision)" />
164 </xsl:otherwise>
165 </xsl:choose>
166 </xsl:variable>
167 <span class="changelog_revision">
168 <a id="r{@revision}" href="{$revlink}">[r<xsl:value-of select="@revision" />]</a>
169 </span>
170 <xsl:text>&space;</xsl:text>
171 <!-- get paths string -->
172 <span class="changelog_files"><xsl:apply-templates select="paths" /></span>
173 <xsl:text>&space;</xsl:text>
174 <!-- get message text -->
175 <xsl:variable name="msg">
176 <xsl:call-template name="trim-newln">
177 <xsl:with-param name="txt" select="msg" />
178 </xsl:call-template>
179 </xsl:variable>
180 <span class="changelog_message">
181 <xsl:call-template name="newlinestobr">
182 <xsl:with-param name="txt" select="$msg" />
183 </xsl:call-template>
184 </span>
185 </li>
186 </xsl:template>
188 <!-- template to replace line breaks with <br /> tags -->
189 <xsl:template name="newlinestobr">
190 <xsl:param name="txt" />
191 <xsl:choose>
192 <xsl:when test="contains($txt,'&newl;')">
193 <!-- text contains newlines, do the first line -->
194 <xsl:value-of select="substring-before($txt,'&newl;')" />
195 <!-- print new line -->
196 <br />
197 <!-- wrap the rest of the text -->
198 <xsl:call-template name="newlinestobr">
199 <xsl:with-param name="txt" select="substring-after($txt,'&newl;')" />
200 </xsl:call-template>
201 </xsl:when>
202 <xsl:otherwise>
203 <xsl:value-of select="$txt" />
204 </xsl:otherwise>
205 </xsl:choose>
206 </xsl:template>
208 </xsl:stylesheet>