Thought folks might be interested in the following XSL which has come
from modifying the modifications.xsl style to be easier to read for
typical check ins on the project I'm working on.

So where the built in template is a line

| type | user | file | comment | date |

for every file.

We're using Perforce so have multiple files per transactional
changelist with longish comments which were getting repeated and hard
to read. The XSL below formats the change as a block

| Change #  | User  | Date  |
|         comment           |
| directory | file  | type  |
| directory | file2 | type  |
...

per changelist.

Hope this is useful to some folks.

Ian

P.S. Submitted to the user list rather than dev list since I'm
assuming its not suitable for replacing the standard template for
everyone as it groups by changeNumber I suspect not every SCM supports/
populates this (CVS? Sourcesafe? Clearcase?). If I'm wrong then feel
free to include it.

----

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="2.0">

    <xsl:output method="html"/>

    <xsl:variable name="modification.list" select="/cruisecontrol/
modifications/modification"/>
    <xsl:key name="modifications-by-changelist" match="modification"
use="changeNumber" />

    <xsl:template match="/">
        <table class="section-table" cellpadding="2" cellspacing="0"
               border="0" width="98%" style="border-collapse:
collapse;" >
            <!-- Modifications -->
            <tr>
                <td class="sectionheader" colspan="5">
                    Modifications since last build (<xsl:value-of
select="count($modification.list)"/>)
                </td>
            </tr>

            <!-- See http://www.jenitennison.com/xslt/grouping/muenchian.html
for an
                  explanation of this grouping trick. -->
            <xsl:for-each select="/cruisecontrol/modifications/
modification[count(. | key('modifications-by-changelist',changeNumber)
[1]) = 1]">
                <xsl:sort select="changeNumber"/>
                <tr style="font-weight: bold;">
                    <td class="" valign="top">
                        <xsl:value-of select="changeNumber"/
>
                    </td>
                    <td class="" valign="top">
                        <xsl:value-of select="user"/>
                    </td>
                    <td class="" valign="top">
                        <xsl:value-of select="date"/>
                    </td>
                </tr>
                <tr style="border-bottom: 1px dotted gray;">
                    <td class="section-data" valign="top" colspan="3">
                        <xsl:value-of select="comment" />
                    </td>
                </tr>
                <xsl:for-each select="key('modifications-by-
changelist', changeNumber)">
                    <xsl:sort select="project" />
                    <tr>
                        <xsl:if test="position() mod 2=0">
                            <xsl:attribute name="class">section-
evenrow</xsl:attribute>
                        </xsl:if>
                        <xsl:if test="position() mod 2!=0">
                            <xsl:attribute name="class">section-
oddrow</xsl:attribute>
                        </xsl:if>
                        <td class="section-data">
                            <xsl:value-of select="project" />
                        </td>
                        <td class="section-data">
                            <xsl:value-of select="filename" />
                        </td>
                        <td class="section-data">
                            <xsl:value-of select="@type"/>
                        </td>
                    </tr>
                </xsl:for-each>
                <tr style="border-bottom: 1px solid;">
                   <td colspan="0"></td>
                </tr>
            </xsl:for-each>
        </table>
    </xsl:template>

    <!-- Modifications template -->
    <xsl:template match="modification">
        <tr>
            <xsl:if test="position() mod 2=0">
                <xsl:attribute name="class">section-oddrow</
xsl:attribute>
            </xsl:if>
            <xsl:if test="position() mod 2!=0">
                <xsl:attribute name="class">section-evenrow</
xsl:attribute>
            </xsl:if>

            <td class="section-data" valign="top"><xsl:value-of
select="@type"/></td>
            <td class="section-data" valign="top"><xsl:value-of
select="user"/></td>
            <td class="section-data" valign="top"><xsl:value-of
select="changeNumber"/></td>
            <td class="section-data" valign="top">
                <xsl:choose>
                        <xsl:when test="count(url) = 1 ">
                                                      <a>
                                                              <xsl:attribute 
name="href">
                                                                      
<xsl:value-of select="url" />
                                                              </xsl:attribute>
                                                              <xsl:if 
test="project != ''"><xsl:value-of
select="project"/>/</xsl:if>
                                                              <xsl:value-of 
select="filename"/>
                                                      </a>
                                              </xsl:when>
                        <xsl:otherwise>
                                                      <xsl:if test="project != 
''"><xsl:value-of
select="project"/>/</xsl:if>
                                                      <xsl:value-of 
select="filename"/>
                                </xsl:otherwise>
                </xsl:choose>
                              </td>
            <td class="section-data" valign="top"><xsl:value-of
select="comment"/></td>
            <td class="section-data" valign="top"><xsl:value-of
select="date"/></td>
        </tr>
    </xsl:template>
</xsl:stylesheet>


-- 
To unsubscribe, reply using "remove me" as the subject.

Reply via email to