First cut. Distintly raw around the edges:
* Assumes it will be running in /home/ali/wk/slashem/web.scripts
* Assumes cache directory will be in topdir
* No build system (simple compiling and linking against libxml2)
* No configure system (eg., tagsoup)
* Output XML untested
* Doesn't set bugzilla maintainer or exporter
* Handling of artifact priorities and resolution is suspect
2 <xsl:stylesheet version="1.0"
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 xmlns:xi="http://www.w3.org/2001/XInclude"
5 xmlns:date="http://exslt.org/dates-and-times"
6 xmlns:sf2bz="http://project.juiblex.co.uk/sf2bz"
7 extension-element-prefixes="date">
9 <xsl:import href="sf2bz.xsl"/>
11 <!-- Return the last change made in an artifact's history -->
12 <xsl:template name="lastchange">
13 <xsl:variable name="dates">
15 select="field[@name='artifact_history']/history/field[@name='entrydate']">
16 <xsl:sort data-type='number' order='descending'/>
17 <xsl:value-of select="."/>
18 <xsl:text>:</xsl:text>
21 <xsl:call-template name="bugzilla-timestamp">
22 <xsl:with-param name="secs" select="substring-before($dates,':')"/>
26 <!-- Process a sourceforge artifact, outputting a bugzilla bug -->
27 <xsl:template name="process-artifact">
29 <xsl:apply-templates/>
32 <xsl:when test="field[@name='artifact_history']">
33 <xsl:call-template name="lastchange"/>
36 <xsl:call-template name="bugzilla-timestamp">
37 <xsl:with-param name="secs" select="field[@name='open_date']"/>
43 select="field[@name='artifact_history']/history[field[@name='field_name']='File Added']">
44 <xsl:element namespace="http://www.w3.org/2001/XInclude" name="include">
45 <xsl:attribute name="href">
46 <xsl:text>cache/attachments/</xsl:text>
48 select="substring-before(field[@name='old_value'],':')"/>
49 <xsl:text>.xml</xsl:text>
51 <xsl:attribute name="xpointer">xpointer(/attachment)</xsl:attribute>
52 <xsl:element namespace="http://www.w3.org/2001/XInclude"
59 <!-- Output a user node -->
60 <xsl:template name="bugzilla-user">
61 <xsl:param name="element">who</xsl:param>
62 <xsl:param name="user" select="."/>
64 <xsl:attribute name="name">
65 <xsl:value-of select="$element"/>
68 <xsl:element namespace="http://www.w3.org/2001/XInclude" name="include">
69 <xsl:attribute name="href">users.xml</xsl:attribute>
70 <xsl:attribute name="xpointer">
71 <xsl:text>xpointer(/users/user[.="</xsl:text>
72 <xsl:value-of select="$user"/>
73 <xsl:text>@users.sourceforge.net"])</xsl:text>
80 <xsl:template match="project_export">
81 <bugzilla version="2.23.3">
82 <xsl:if test="news/field[@name='group_id']/@group_id">
83 <xsl:attribute name="urlbase">
84 <xsl:text>https://sourceforge.net/tracker/?group_id=</xsl:text>
85 <xsl:value-of select="news/field[@name='group_id']/@group_id"/>
88 <xsl:apply-templates/>
92 <xsl:template match="artifacts">
93 <xsl:apply-templates/>
96 <xsl:template match="artifact">
97 <xsl:variable name="type"
98 select="normalize-space(field[@name='artifact_type'])"/>
100 <xsl:when test="$type = 'Feature Requests'">
101 <xsl:call-template name="process-artifact"/>
103 <xsl:when test="$type = 'Patches'">
104 <xsl:call-template name="process-artifact"/>
106 <xsl:when test="$type = 'Bugs'">
107 <xsl:call-template name="process-artifact"/>
112 <xsl:template match="field[@name='artifact_id']">
113 <bug_id><xsl:value-of select="."/></bug_id>
116 <xsl:template match="field[@name='submitted_by']">
117 <xsl:call-template name="bugzilla-user">
118 <xsl:with-param name="element">reporter</xsl:with-param>
122 <xsl:template match="field[@name='assigned_to']">
123 <xsl:if test="normalize-space(.)!='nobody'">
124 <xsl:call-template name="bugzilla-user">
125 <xsl:with-param name="element">assigned_to</xsl:with-param>
130 <xsl:template match="field[@name='priority']">
133 <xsl:when test="number(.)>8">P5</xsl:when>
134 <xsl:when test="number(.)>5">P4</xsl:when>
135 <xsl:when test="number(.)=5">P3</xsl:when>
136 <xsl:when test="number(.)>1">P2</xsl:when>
137 <xsl:otherwise>P1</xsl:otherwise>
142 <xsl:template match="field[@name='status']">
145 <xsl:when test="normalize-space(.)='Open'">
148 test="normalize-space(../field[@name='assigned_to'])='nobody'">
149 <xsl:text>UNCONFIRMED</xsl:text>
151 <xsl:otherwise>ASSIGNED</xsl:otherwise>
154 <xsl:when test="normalize-space(.)='Pending'">NEW</xsl:when>
155 <xsl:otherwise>RESOLVED</xsl:otherwise>
160 <xsl:template match="field[@name='summary']">
161 <short_desc><xsl:value-of select="."/></short_desc>
164 <xsl:template match="field[@name='open_date']">
166 <xsl:call-template name="bugzilla-timestamp"/>
170 <xsl:template match="field[@name='artifact_type']">
171 <xsl:variable name="pri"
172 select="normalize-space(../field[@name='priority'])"/>
175 <xsl:when test="normalize-space(.)='Bugs'">
177 <xsl:when test="$pri>=9">blocker</xsl:when>
178 <xsl:when test="$pri=8">critical</xsl:when>
179 <xsl:when test="$pri<8 and $pri>5">major</xsl:when>
180 <xsl:when test="$pri<5 and $pri>2">minor</xsl:when>
181 <xsl:when test="$pri<=2">trivial</xsl:when>
182 <xsl:otherwise>normal</xsl:otherwise>
185 <xsl:otherwise>enhancement</xsl:otherwise>
190 <xsl:template match="field[@name='category']">
191 <component><xsl:value-of select="."/></component>
194 <xsl:template match="field[@name='artifact_group_id']">
195 <version><xsl:value-of select="."/></version>
198 <xsl:template match="field[@name='details']">
200 <xsl:call-template name="bugzilla-user">
201 <xsl:with-param name="user" select="../field[@name='submitted_by']"/>
204 <xsl:call-template name="bugzilla-timestamp">
205 <xsl:with-param name="secs" select="../field[@name='open_date']"/>
208 <thetext><xsl:value-of select="."/></thetext>
212 <xsl:template match="field[@name='artifact_messages']">
213 <xsl:apply-templates/>
216 <xsl:template match="message">
218 <xsl:call-template name="bugzilla-user">
219 <xsl:with-param name="user" select="field[@name='user_name']"/>
222 <xsl:call-template name="bugzilla-timestamp">
223 <xsl:with-param name="secs" select="field[@name='adddate']"/>
227 <!-- Sourceforge puts either "Logged In: YES \n;user_id=%user\n\n" or
228 "Logged In: NO\n\n" at the start of each message body. -->
229 <xsl:value-of select="substring-after(field[@name='body'],' ')"/>
234 <xsl:template match="node()|text()" priority="-1"></xsl:template>