Generating an SVN Log File in a HTML Format

Basically, we can see our SVN history from IDE, but today i have a very weird request from one of my user, they want to see our svn logs progress but in HTML format. After sometimes googling, i found a workaround using XSLT to change svn log XML output file into HTML file.

This is how i do it, i run this command from command prompt, dont forget to register svn.exe on your environment.

svn log -v --limit 100 --xml > outfile.xml

it will create an xml file (outfile.xml) which consist of last 100 svn commit logs.

Next is creating an xsl file, style.xsl, which will become our html template file.

<?xml version="1.0" encoding="ISO-8859-1"?>  
<xsl:stylesheet version="2.0"  
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">  
<xsl:template match="/">  
<html>  
<body>  
<h2>Versioning Log</h2>  
<table border="1" style="table-layout:fixed;width: 100%;">
	<tr>
		<td width="5%">Rev No.</td>
		<td width="10%">
				Date				
		</td>
		<td width="5%">
					Author
				
		</td>
		<td width="">
					Message
				
		</td>
	</tr>
	<xsl:for-each select="log/logentry">  
		<tr>			
			<td>				
				<pre><xsl:value-of select="@revision"/> </pre>
			</td>			
			<td>
				<pre><xsl:value-of select="substring(date, 0, 11)" /></pre>
			</td>		
			<td>
				<pre>
					<xsl:value-of select="author"/> 
				</pre>
			</td>		
			<td>			
				<pre>
					<xsl:value-of select="msg"/>
				</pre>
			</td>
		</tr>
	</xsl:for-each>  
</table>  
</body>  
</html>  
</xsl:template>  
</xsl:stylesheet>  

Next step is converting outfile.xml into html file, im using saxon library for handling this. I run this command from command prompt, it will create a html file.

java -jar saxon9he.jar -o:version.html outfile.xml style.xsl

The final result is version.html, which looks like this,
svn versioning html

With a little effort, it’s not so hard to automate this task via maven task. ;)

Google+

No Comments

Leave a Comment

Please be polite. We appreciate that.
Your email address will not be published and required fields are marked


:-[ (B) (^) (P) (@) (O) (D) :-S ;-( (C) (&) :-$ (E) (~) (K) (I) (L) (8) :-O (T) (G) (F) :-( (H) :-) (*) :-D (N) (Y) :-P (U) (W) ;-)