Warning, /graphics/kst-plot/svn2cl.xsl is written in an unsupported language. File is not indexed.
0001 <?xml version="1.0" encoding="utf-8"?> 0002 0003 <!-- 0004 0005 svn2cl.xsl - xslt stylesheet for converting svn log to a normal 0006 changelog 0007 0008 This file is based on several implementations of this conversion 0009 that I was not completely happy with and some other common 0010 xslt constructs found on the web. 0011 0012 Copyright (C) 2004 Arthur de Jong. 0013 0014 Redistribution and use in source and binary forms, with or without 0015 modification, are permitted provided that the following conditions 0016 are met: 0017 1. Redistributions of source code must retain the above copyright 0018 notice, this list of conditions and the following disclaimer. 0019 2. Redistributions in binary form must reproduce the above copyright 0020 notice, this list of conditions and the following disclaimer in 0021 the documentation and/or other materials provided with the 0022 distribution. 0023 3. The name of the author may not be used to endorse or promote 0024 products derived from this software without specific prior 0025 written permission. 0026 0027 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 0028 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 0029 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 0030 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 0031 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 0032 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 0033 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 0034 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 0035 IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 0036 OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 0037 IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 0038 0039 --> 0040 0041 <!-- 0042 TODO 0043 - make external lookups of author names possible 0044 - find a place for revision numbers 0045 - mark deleted files as such 0046 - combine paths 0047 - make stripping of characters nicer 0048 --> 0049 0050 <xsl:stylesheet 0051 version="1.0" 0052 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 0053 xmlns="http://www.w3.org/1999/xhtml"> 0054 0055 <xsl:output 0056 method="text" 0057 encoding="iso-8859-15" 0058 media-type="text/plain" 0059 omit-xml-declaration="yes" 0060 standalone="yes" 0061 indent="no" /> 0062 0063 <xsl:strip-space elements="*" /> 0064 0065 <!-- the prefix of pathnames to strip --> 0066 <xsl:param name="strip-prefix" select="'/'" /> 0067 0068 <!-- format one entry from the log --> 0069 <xsl:template match="logentry"> 0070 <!-- date --> 0071 <xsl:apply-templates select="date" /> 0072 <!-- two spaces --> 0073 <xsl:text> </xsl:text> 0074 <!-- author's name --> 0075 <xsl:apply-templates select="author" /> 0076 <!-- two newlines --> 0077 <xsl:text> 0078 0079 </xsl:text> 0080 <!-- the log message --> 0081 <xsl:apply-templates select="msg" /> 0082 <!-- another two newlines --> 0083 <xsl:text> 0084 0085 </xsl:text> 0086 </xsl:template> 0087 0088 <!-- format date --> 0089 <xsl:template match="date"> 0090 <xsl:variable name="date" select="normalize-space(.)" /> 0091 <xsl:value-of select="substring($date,1,10)" /> 0092 <xsl:text> </xsl:text> 0093 <xsl:value-of select="substring($date,12,5)" /> 0094 </xsl:template> 0095 0096 <!-- format author --> 0097 <xsl:template match="author"> 0098 <xsl:value-of select="normalize-space(.)" /> 0099 </xsl:template> 0100 0101 <!-- format log message --> 0102 <xsl:template match="msg"> 0103 <!-- first line is indented (other indents are done in wrap template) --> 0104 <xsl:text> * </xsl:text> 0105 <!-- get paths string --> 0106 <xsl:variable name="paths"> 0107 <xsl:apply-templates select="../paths" /> 0108 </xsl:variable> 0109 <!-- print the paths and message nicely wrapped --> 0110 <xsl:call-template name="wrap"> 0111 <xsl:with-param name="txt" select="concat($paths,': ',normalize-space(.))" /> 0112 </xsl:call-template> 0113 </xsl:template> 0114 0115 <!-- present paths nice --> 0116 <xsl:template match="paths"> 0117 <xsl:for-each select="path"> 0118 <xsl:sort select="normalize-space(.)" data-type="text" /> 0119 <xsl:if test="not(position()=1)"> 0120 <xsl:text>, </xsl:text> 0121 </xsl:if> 0122 <xsl:variable name="p1" select="normalize-space(.)" /> 0123 <xsl:variable name="p2"> 0124 <xsl:choose> 0125 <xsl:when test="starts-with($p1,'/')"> 0126 <xsl:value-of select="substring($p1,2)" /> 0127 </xsl:when> 0128 <xsl:otherwise> 0129 <xsl:value-of select="$p1" /> 0130 </xsl:otherwise> 0131 </xsl:choose> 0132 </xsl:variable> 0133 <xsl:variable name="p3"> 0134 <xsl:choose> 0135 <xsl:when test="starts-with($p2,$strip-prefix)"> 0136 <xsl:value-of select="substring($p2,1+string-length($strip-prefix))" /> 0137 </xsl:when> 0138 <xsl:otherwise> 0139 <xsl:value-of select="$p2" /> 0140 </xsl:otherwise> 0141 </xsl:choose> 0142 </xsl:variable> 0143 <xsl:variable name="p4"> 0144 <xsl:choose> 0145 <xsl:when test="starts-with($p3,'/')"> 0146 <xsl:value-of select="substring($p3,2)" /> 0147 </xsl:when> 0148 <xsl:otherwise> 0149 <xsl:value-of select="$p3" /> 0150 </xsl:otherwise> 0151 </xsl:choose> 0152 </xsl:variable> 0153 <xsl:choose> 0154 <xsl:when test="$p4 = ''"> 0155 <xsl:value-of select="'.'" /> 0156 </xsl:when> 0157 <xsl:otherwise> 0158 <xsl:value-of select="$p4" /> 0159 </xsl:otherwise> 0160 </xsl:choose> 0161 </xsl:for-each> 0162 </xsl:template> 0163 0164 <!-- string-wrapping template --> 0165 <xsl:template name="wrap"> 0166 <xsl:param name="txt" /> 0167 <xsl:variable name="linelen" select="67" /> 0168 <xsl:choose> 0169 <xsl:when test="(string-length($txt) < $linelen) or not(contains($txt,' '))"> 0170 <!-- this is easy, nothing to do --> 0171 <xsl:value-of select="$txt" /> 0172 </xsl:when> 0173 <xsl:otherwise> 0174 <!-- find the first line --> 0175 <xsl:variable name="tmp" select="substring($txt,1,$linelen)" /> 0176 <xsl:variable name="line"> 0177 <xsl:choose> 0178 <xsl:when test="contains($tmp,' ')"> 0179 <xsl:call-template name="find-line"> 0180 <xsl:with-param name="txt" select="$tmp" /> 0181 </xsl:call-template> 0182 </xsl:when> 0183 <xsl:otherwise> 0184 <xsl:value-of select="substring-before($txt,' ')" /> 0185 </xsl:otherwise> 0186 </xsl:choose> 0187 </xsl:variable> 0188 <!-- print line and newline --> 0189 <xsl:value-of select="$line" /> 0190 <xsl:text> 0191 </xsl:text> 0192 <!-- wrap the rest of the text --> 0193 <xsl:call-template name="wrap"> 0194 <xsl:with-param name="txt" select="normalize-space(substring($txt,string-length($line)+1))" /> 0195 </xsl:call-template> 0196 </xsl:otherwise> 0197 </xsl:choose> 0198 </xsl:template> 0199 0200 <!-- template to trim line to contain space as last char --> 0201 <xsl:template name="find-line"> 0202 <xsl:param name="txt" /> 0203 <xsl:choose> 0204 <xsl:when test="substring($txt,string-length($txt),1) = ' '"> 0205 <xsl:value-of select="normalize-space($txt)" /> 0206 </xsl:when> 0207 <xsl:otherwise> 0208 <xsl:call-template name="find-line"> 0209 <xsl:with-param name="txt" select="substring($txt,1,string-length($txt)-1)" /> 0210 </xsl:call-template> 0211 </xsl:otherwise> 0212 </xsl:choose> 0213 </xsl:template> 0214 0215 </xsl:stylesheet>