annotate bug-list.xsl @ 2:14caabdb946b

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