0
|
1 <?xml version="1.0" encoding="UTF-8"?>
|
|
2 <xsl:stylesheet version="1.0"
|
1
|
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common">
|
|
4 <xsl:output method="xml" indent="yes" />
|
|
5 <xsl:key name="bugid" match="bug" use="bug_id" />
|
|
6 <xsl:variable name="roots"
|
|
7 select="bugzilla/bug[not(blocked[key('bugid',.)])]" />
|
|
8
|
|
9 <!-- BUILD BUG TREE -->
|
|
10 <xsl:variable name="tree">
|
|
11 <xsl:apply-templates mode="tree" select="$roots" />
|
|
12 </xsl:variable>
|
|
13
|
|
14 <xsl:template match="bug" mode="tree">
|
|
15 <xsl:element name="bug">
|
|
16 <xsl:attribute name="id"><xsl:value-of select="bug_id" /></xsl:attribute>
|
|
17 <xsl:if test="component = 'product'">
|
|
18 <xsl:attribute name="product"><xsl:value-of select="boolean(1)" /></xsl:attribute>
|
|
19 </xsl:if>
|
|
20 <xsl:for-each select="dependson">
|
|
21 <xsl:apply-templates mode="tree" select="key('bugid', .)" />
|
|
22 </xsl:for-each>
|
|
23 </xsl:element>
|
|
24 </xsl:template>
|
|
25
|
|
26 <!-- CALCULATE RELATIONS -->
|
|
27 <xsl:variable name="relations">
|
|
28 <xsl:apply-templates select="bugzilla/bug" mode="relations" />
|
|
29 </xsl:variable>
|
|
30
|
|
31 <xsl:template match="bug" mode="relations">
|
|
32 <xsl:variable name="bugid" select="string(bug_id)" />
|
|
33 <bug id="{$bugid}">
|
|
34 <xsl:apply-templates select="exsl:node-set($tree)//bug[@id = $bugid]"
|
|
35 mode="traverse-relations">
|
|
36 </xsl:apply-templates>
|
|
37 </bug>
|
|
38 </xsl:template>
|
|
39
|
|
40 <xsl:template match="bug" mode="traverse-relations">
|
|
41 <xsl:variable name="bugid" select="@id" />
|
|
42 <xsl:variable name="level" select="count(ancestor::node())" />
|
|
43 <path>
|
|
44 <xsl:for-each select="ancestor::node()">
|
|
45 <bug id="{@id}" product="{@product}"/>
|
|
46 </xsl:for-each>
|
|
47 </path>
|
|
48 <xsl:for-each select="ancestor::bug[@product]">
|
|
49 <xsl:variable name="rank" select="$level - position()" />
|
|
50 <rel container="{@id}" rank="{$rank}" level="{$level}"/>
|
|
51 </xsl:for-each>
|
|
52 </xsl:template>
|
|
53
|
|
54 <!-- CALCULATE STRUCTURE -->
|
|
55
|
|
56 <xsl:variable name="structure">
|
|
57 <xsl:apply-templates select="exsl:node-set($relations)"
|
|
58 mode="structure" />
|
|
59 </xsl:variable>
|
|
60
|
|
61 <xsl:template match="bug" mode="structure">
|
|
62 <xsl:variable name="parent"
|
|
63 select="rel[ not(../rel/@rank < @rank) ][1]/@container" />
|
|
64 <bug id="{@id}" container="{$parent}" />
|
|
65 </xsl:template>
|
|
66
|
|
67 <!-- -->
|
0
|
68 <xsl:template match="/">
|
1
|
69 <root>
|
|
70 <xsl:copy-of select="$tree" />
|
|
71 <xsl:copy-of select="$relations" />
|
|
72 <xsl:copy-of select="$structure" />
|
|
73 </root>
|
0
|
74 </xsl:template>
|
|
75
|
|
76 <xsl:template match="bug">
|
1
|
77 <xsl:value-of select="bug_id" />
|
|
78 <xsl:text>
</xsl:text>
|
|
79 </xsl:template>
|
|
80
|
|
81 <xsl:template match="bug[component = 'product']">
|
|
82 <xsl:value-of select="bug_id" />
|
|
83 <xsl:text>:
</xsl:text>
|
|
84 <xsl:for-each select="dependson">
|
|
85 <xsl:apply-templates select="key('bugid', .)" />
|
|
86 </xsl:for-each>
|
|
87 <xsl:text>---END---
</xsl:text>
|
0
|
88 </xsl:template>
|
|
89
|
|
90 <xsl:template match="text()" />
|
|
91
|
|
92 <xsl:template name="bug-template">
|
|
93 <xsl:param name="indent" select="0" />
|
|
94 <xsl:variable name="isOrganizing" select="component = 'product'"></xsl:variable>
|
|
95
|
|
96 <xsl:call-template name="start-task">
|
|
97 <xsl:with-param name="indent" select="$indent" />
|
|
98 </xsl:call-template>
|
|
99
|
|
100 <xsl:if test="$isOrganizing">
|
|
101
|
|
102 </xsl:if>
|
|
103
|
|
104 <xsl:choose>
|
|
105 <xsl:when test="$isOrganizing">
|
|
106 <xsl:for-each select="dependson">
|
|
107 <xsl:for-each select="key('bugs-key', .)">
|
|
108 <xsl:call-template name="bug-template">
|
|
109 <xsl:with-param name="indent" select="$indent + 1" />
|
|
110 </xsl:call-template>
|
|
111 </xsl:for-each>
|
|
112 </xsl:for-each>
|
|
113 </xsl:when>
|
|
114 <xsl:otherwise>
|
|
115 <xsl:if test="number(estimated_time)">
|
|
116 <xsl:call-template name="begin-line">
|
|
117 <xsl:with-param name="indent" select="$indent + 1" />
|
|
118 </xsl:call-template>
|
|
119 <xsl:value-of select="concat('effort ', estimated_time, 'h')" />
|
|
120 <xsl:call-template name="end-line" />
|
|
121 </xsl:if>
|
|
122 </xsl:otherwise>
|
|
123 </xsl:choose>
|
|
124
|
|
125 <xsl:call-template name="end-task">
|
|
126 <xsl:with-param name="indent" select="$indent" />
|
|
127 </xsl:call-template>
|
|
128 </xsl:template>
|
|
129
|
|
130 <xsl:template name="make-bug-id">
|
|
131 <xsl:param name="id"></xsl:param>
|
|
132 <xsl:value-of select="concat('bug', $id)"></xsl:value-of>
|
|
133 </xsl:template>
|
|
134
|
|
135 <xsl:template name="start-task">
|
|
136 <xsl:param name="indent" />
|
|
137 <xsl:call-template name="begin-line">
|
|
138 <xsl:with-param name="indent" select="$indent" />
|
|
139 </xsl:call-template>
|
|
140 <xsl:text>task </xsl:text>
|
|
141 <xsl:call-template name="make-bug-id">
|
|
142 <xsl:with-param name="id" select="bug_id" />
|
|
143 </xsl:call-template>
|
|
144 <xsl:value-of select="concat(' "',short_desc,'" {')" />
|
|
145 <xsl:call-template name="end-line" />
|
|
146 </xsl:template>
|
|
147
|
|
148 <xsl:template name="end-task">
|
|
149 <xsl:param name="indent" />
|
|
150 <xsl:call-template name="begin-line">
|
|
151 <xsl:with-param name="indent" select="$indent" />
|
|
152 </xsl:call-template>
|
|
153 <xsl:text>}</xsl:text>
|
|
154 <xsl:call-template name="end-line" />
|
|
155 </xsl:template>
|
|
156
|
|
157 <xsl:template name="begin-line">
|
|
158 <xsl:param name="indent" />
|
|
159 <xsl:if test="number($indent) > 0">
|
|
160 <xsl:text> </xsl:text>
|
|
161 <xsl:call-template name="begin-line">
|
|
162 <xsl:with-param name="indent" select="$indent - 1" />
|
|
163 </xsl:call-template>
|
|
164 </xsl:if>
|
|
165 </xsl:template>
|
|
166 <xsl:template name="end-line">
|
|
167 <xsl:text>
</xsl:text>
|
|
168 </xsl:template>
|
|
169 </xsl:stylesheet> |