Cette feuille de styles XSL est utilisée avec xsltproc pour transformer le journal XML de Subversion en une page Web XHTML. Elle prend en compte les balises XML insérées pour la publication des statistiques diffstat.
<?xml version='1.0'?>
<!--
Another SVN 2 Changelog conversion
asvn2cl.xsl - xslt stylesheet for converting svn log to a
XHTML changelog
Cette feuille de styles XSL est basée sur la génération de
changelog GNU au format texte. Elle est adaptée pour produire
une page Web au format XHTML. L'introduction ci-dessous reste
parfaitement valable ;)).
This file is based on several implementations of this conversion
that I was not completely happy with and some other common
xslt constructs found on the web.
Copyright (C) 2005, 2007 Philippe Latu.
Copyright (C) 2004 Arthur de Jong.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. The name of the author may not be used to endorse or promote
products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml">
<xsl:output
method="html"
encoding="utf-8"
standalone="yes"
indent="yes" />
<xsl:strip-space elements="*" />
<!-- the prefix of pathnames to strip -->
<xsl:param name="strip-prefix" select="'/trunk/'" />
<!-- format date -->
<xsl:template match="date">
<xsl:variable name="date" select="normalize-space(.)" />
<xsl:value-of select="substring($date,1,10)" />
<xsl:text> </xsl:text>
<xsl:value-of select="substring($date,12,5)" />
</xsl:template>
<!-- format author -->
<xsl:template match="author">
<xsl:value-of select="normalize-space(.)" />
</xsl:template>
<!-- format de la cellule stats -->
<xsl:template match="stats">
<xsl:if test="string(text())">
<xsl:text> </xsl:text>
</xsl:if>
<xsl:value-of select="normalize-space(.)" />
</xsl:template>
<!-- extraction du nom de répertoire -->
<xsl:template name="dirname">
<xsl:param name="path" />
<xsl:if test="contains($path, '/')">
<xsl:value-of select="concat(substring-before($path, '/'), '/')" />
<xsl:call-template name="dirname">
<xsl:with-param name="path"
select="substring-after($path, '/')" />
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template match="path">
<td>
<xsl:value-of select="@action"/>
</td>
<td>
<xsl:choose>
<xsl:when test="contains(text(), 'prj')">
<xsl:choose>
<!-- pas de lien pour une image -->
<xsl:when test="contains(text(), 'image')">
<xsl:value-of select="substring(text(),1+string-length($strip-prefix))" />
</xsl:when>
<!-- lien sur le répertoire de l'objet modifié -->
<xsl:otherwise>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:call-template name="dirname">
<xsl:with-param name="path"
select="substring(text(),string-length($strip-prefix))"/>
</xsl:call-template>
</xsl:attribute>
<xsl:value-of select="substring(text(),1+string-length($strip-prefix))"/>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="substring(text(),1+string-length($strip-prefix))" />
</xsl:otherwise>
</xsl:choose>
</td>
</xsl:template>
<!-- format de l'objet courant -->
<xsl:template match="object">
<tr>
<xsl:apply-templates select="path"/>
<td>
<xsl:apply-templates select="stats"/>
</td>
</tr>
</xsl:template>
<xsl:template match="/log">
<html>
<head>
<title>SVN ChangeLog [inetdoc.LINUX]</title>
</head>
<body>
<div id='sitemast' style='margin: 0px; padding: 0px;'>
<h1 style='font-size: 150%;'>SVN ChangeLog [inetdoc.LINUX]</h1>
</div>
<xsl:for-each select="logentry">
<h4>
<!-- revision -->
<xsl:text>Révision : </xsl:text>
<xsl:value-of select="@revision"/>
<xsl:text> / </xsl:text>
<!-- date -->
<xsl:text>Date : </xsl:text>
<xsl:apply-templates select="date" />
<xsl:text> / </xsl:text>
<!-- author's name -->
<xsl:text>Auteur : </xsl:text>
<xsl:apply-templates select="author" />
</h4>
<div class='revhistory'>
<table>
<tr>
<th>Action</th>
<th>Fichier</th>
<th>Statistiques</th>
</tr>
<xsl:for-each select="objects">
<xsl:apply-templates select="object"/>
</xsl:for-each>
</table>
</div>
<pre>
<xsl:value-of select="msg" />
</pre>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Vous êtes ici :