1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/bugzilla.xsl Thu Nov 16 08:30:26 2006 +0000
1.3 @@ -0,0 +1,236 @@
1.4 +<?xml version="1.0"?>
1.5 +<xsl:stylesheet version="1.0"
1.6 + xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
1.7 + xmlns:xi="http://www.w3.org/2001/XInclude"
1.8 + xmlns:date="http://exslt.org/dates-and-times"
1.9 + xmlns:sf2bz="http://project.juiblex.co.uk/sf2bz"
1.10 + extension-element-prefixes="date">
1.11 +
1.12 +<xsl:import href="sf2bz.xsl"/>
1.13 +
1.14 +<!-- Return the last change made in an artifact's history -->
1.15 +<xsl:template name="lastchange">
1.16 + <xsl:variable name="dates">
1.17 + <xsl:for-each
1.18 + select="field[@name='artifact_history']/history/field[@name='entrydate']">
1.19 + <xsl:sort data-type='number' order='descending'/>
1.20 + <xsl:value-of select="."/>
1.21 + <xsl:text>:</xsl:text>
1.22 + </xsl:for-each>
1.23 + </xsl:variable>
1.24 + <xsl:call-template name="bugzilla-timestamp">
1.25 + <xsl:with-param name="secs" select="substring-before($dates,':')"/>
1.26 + </xsl:call-template>
1.27 +</xsl:template>
1.28 +
1.29 +<!-- Process a sourceforge artifact, outputting a bugzilla bug -->
1.30 +<xsl:template name="process-artifact">
1.31 + <bug>
1.32 + <xsl:apply-templates/>
1.33 + <delta_ts>
1.34 + <xsl:choose>
1.35 + <xsl:when test="field[@name='artifact_history']">
1.36 + <xsl:call-template name="lastchange"/>
1.37 + </xsl:when>
1.38 + <xsl:otherwise>
1.39 + <xsl:call-template name="bugzilla-timestamp">
1.40 + <xsl:with-param name="secs" select="field[@name='open_date']"/>
1.41 + </xsl:call-template>
1.42 + </xsl:otherwise>
1.43 + </xsl:choose>
1.44 + </delta_ts>
1.45 + <xsl:for-each
1.46 + select="field[@name='artifact_history']/history[field[@name='field_name']='File Added']">
1.47 + <xsl:element namespace="http://www.w3.org/2001/XInclude" name="include">
1.48 + <xsl:attribute name="href">
1.49 + <xsl:text>cache/attachments/</xsl:text>
1.50 + <xsl:value-of
1.51 + select="substring-before(field[@name='old_value'],':')"/>
1.52 + <xsl:text>.xml</xsl:text>
1.53 + </xsl:attribute>
1.54 + <xsl:attribute name="xpointer">xpointer(/attachment)</xsl:attribute>
1.55 + <xsl:element namespace="http://www.w3.org/2001/XInclude"
1.56 + name="fallback"/>
1.57 + </xsl:element>
1.58 + </xsl:for-each>
1.59 + </bug>
1.60 +</xsl:template>
1.61 +
1.62 +<!-- Output a user node -->
1.63 +<xsl:template name="bugzilla-user">
1.64 + <xsl:param name="element">who</xsl:param>
1.65 + <xsl:param name="user" select="."/>
1.66 + <sf2bz:element>
1.67 + <xsl:attribute name="name">
1.68 + <xsl:value-of select="$element"/>
1.69 + </xsl:attribute>
1.70 + <sf2bz:copy-from>
1.71 + <xsl:element namespace="http://www.w3.org/2001/XInclude" name="include">
1.72 + <xsl:attribute name="href">users.xml</xsl:attribute>
1.73 + <xsl:attribute name="xpointer">
1.74 + <xsl:text>xpointer(/users/user[.="</xsl:text>
1.75 + <xsl:value-of select="$user"/>
1.76 + <xsl:text>@users.sourceforge.net"])</xsl:text>
1.77 + </xsl:attribute>
1.78 + </xsl:element>
1.79 + </sf2bz:copy-from>
1.80 + </sf2bz:element>
1.81 +</xsl:template>
1.82 +
1.83 +<xsl:template match="project_export">
1.84 + <bugzilla version="2.23.3">
1.85 + <xsl:if test="news/field[@name='group_id']/@group_id">
1.86 + <xsl:attribute name="urlbase">
1.87 + <xsl:text>https://sourceforge.net/tracker/?group_id=</xsl:text>
1.88 + <xsl:value-of select="news/field[@name='group_id']/@group_id"/>
1.89 + </xsl:attribute>
1.90 + </xsl:if>
1.91 + <xsl:apply-templates/>
1.92 + </bugzilla>
1.93 +</xsl:template>
1.94 +
1.95 +<xsl:template match="artifacts">
1.96 + <xsl:apply-templates/>
1.97 +</xsl:template>
1.98 +
1.99 +<xsl:template match="artifact">
1.100 + <xsl:variable name="type"
1.101 + select="normalize-space(field[@name='artifact_type'])"/>
1.102 + <xsl:choose>
1.103 + <xsl:when test="$type = 'Feature Requests'">
1.104 + <xsl:call-template name="process-artifact"/>
1.105 + </xsl:when>
1.106 + <xsl:when test="$type = 'Patches'">
1.107 + <xsl:call-template name="process-artifact"/>
1.108 + </xsl:when>
1.109 + <xsl:when test="$type = 'Bugs'">
1.110 + <xsl:call-template name="process-artifact"/>
1.111 + </xsl:when>
1.112 + </xsl:choose>
1.113 +</xsl:template>
1.114 +
1.115 +<xsl:template match="field[@name='artifact_id']">
1.116 + <bug_id><xsl:value-of select="."/></bug_id>
1.117 +</xsl:template>
1.118 +
1.119 +<xsl:template match="field[@name='submitted_by']">
1.120 + <xsl:call-template name="bugzilla-user">
1.121 + <xsl:with-param name="element">reporter</xsl:with-param>
1.122 + </xsl:call-template>
1.123 +</xsl:template>
1.124 +
1.125 +<xsl:template match="field[@name='assigned_to']">
1.126 + <xsl:if test="normalize-space(.)!='nobody'">
1.127 + <xsl:call-template name="bugzilla-user">
1.128 + <xsl:with-param name="element">assigned_to</xsl:with-param>
1.129 + </xsl:call-template>
1.130 + </xsl:if>
1.131 +</xsl:template>
1.132 +
1.133 +<xsl:template match="field[@name='priority']">
1.134 + <priority>
1.135 + <xsl:choose>
1.136 + <xsl:when test="number(.)>8">P5</xsl:when>
1.137 + <xsl:when test="number(.)>5">P4</xsl:when>
1.138 + <xsl:when test="number(.)=5">P3</xsl:when>
1.139 + <xsl:when test="number(.)>1">P2</xsl:when>
1.140 + <xsl:otherwise>P1</xsl:otherwise>
1.141 + </xsl:choose>
1.142 + </priority>
1.143 +</xsl:template>
1.144 +
1.145 +<xsl:template match="field[@name='status']">
1.146 + <bug_status>
1.147 + <xsl:choose>
1.148 + <xsl:when test="normalize-space(.)='Open'">
1.149 + <xsl:choose>
1.150 + <xsl:when
1.151 + test="normalize-space(../field[@name='assigned_to'])='nobody'">
1.152 + <xsl:text>UNCONFIRMED</xsl:text>
1.153 + </xsl:when>
1.154 + <xsl:otherwise>ASSIGNED</xsl:otherwise>
1.155 + </xsl:choose>
1.156 + </xsl:when>
1.157 + <xsl:when test="normalize-space(.)='Pending'">NEW</xsl:when>
1.158 + <xsl:otherwise>RESOLVED</xsl:otherwise>
1.159 + </xsl:choose>
1.160 + </bug_status>
1.161 +</xsl:template>
1.162 +
1.163 +<xsl:template match="field[@name='summary']">
1.164 + <short_desc><xsl:value-of select="."/></short_desc>
1.165 +</xsl:template>
1.166 +
1.167 +<xsl:template match="field[@name='open_date']">
1.168 + <creation_ts>
1.169 + <xsl:call-template name="bugzilla-timestamp"/>
1.170 + </creation_ts>
1.171 +</xsl:template>
1.172 +
1.173 +<xsl:template match="field[@name='artifact_type']">
1.174 + <xsl:variable name="pri"
1.175 + select="normalize-space(../field[@name='priority'])"/>
1.176 + <bug_severity>
1.177 + <xsl:choose>
1.178 + <xsl:when test="normalize-space(.)='Bugs'">
1.179 + <xsl:choose>
1.180 + <xsl:when test="$pri>=9">blocker</xsl:when>
1.181 + <xsl:when test="$pri=8">critical</xsl:when>
1.182 + <xsl:when test="$pri<8 and $pri>5">major</xsl:when>
1.183 + <xsl:when test="$pri<5 and $pri>2">minor</xsl:when>
1.184 + <xsl:when test="$pri<=2">trivial</xsl:when>
1.185 + <xsl:otherwise>normal</xsl:otherwise>
1.186 + </xsl:choose>
1.187 + </xsl:when>
1.188 + <xsl:otherwise>enhancement</xsl:otherwise>
1.189 + </xsl:choose>
1.190 + </bug_severity>
1.191 +</xsl:template>
1.192 +
1.193 +<xsl:template match="field[@name='category']">
1.194 + <component><xsl:value-of select="."/></component>
1.195 +</xsl:template>
1.196 +
1.197 +<xsl:template match="field[@name='artifact_group_id']">
1.198 + <version><xsl:value-of select="."/></version>
1.199 +</xsl:template>
1.200 +
1.201 +<xsl:template match="field[@name='details']">
1.202 + <long-desc>
1.203 + <xsl:call-template name="bugzilla-user">
1.204 + <xsl:with-param name="user" select="../field[@name='submitted_by']"/>
1.205 + </xsl:call-template>
1.206 + <bug_when>
1.207 + <xsl:call-template name="bugzilla-timestamp">
1.208 + <xsl:with-param name="secs" select="../field[@name='open_date']"/>
1.209 + </xsl:call-template>
1.210 + </bug_when>
1.211 + <thetext><xsl:value-of select="."/></thetext>
1.212 + </long-desc>
1.213 +</xsl:template>
1.214 +
1.215 +<xsl:template match="field[@name='artifact_messages']">
1.216 + <xsl:apply-templates/>
1.217 +</xsl:template>
1.218 +
1.219 +<xsl:template match="message">
1.220 + <long-desc>
1.221 + <xsl:call-template name="bugzilla-user">
1.222 + <xsl:with-param name="user" select="field[@name='user_name']"/>
1.223 + </xsl:call-template>
1.224 + <bug_when>
1.225 + <xsl:call-template name="bugzilla-timestamp">
1.226 + <xsl:with-param name="secs" select="field[@name='adddate']"/>
1.227 + </xsl:call-template>
1.228 + </bug_when>
1.229 + <thetext>
1.230 + <!-- Sourceforge puts either "Logged In: YES \n;user_id=%user\n\n" or
1.231 + "Logged In: NO\n\n" at the start of each message body. -->
1.232 + <xsl:value-of select="substring-after(field[@name='body'],' ')"/>
1.233 + </thetext>
1.234 + </long-desc>
1.235 +</xsl:template>
1.236 +
1.237 +<xsl:template match="node()|text()" priority="-1"></xsl:template>
1.238 +
1.239 +</xsl:stylesheet>