Mercurial > pub > buggler
comparison bug-list.xsl @ 1:d1400de5832b
improved xsl
author | cin |
---|---|
date | Fri, 21 Aug 2015 20:07:52 +0300 |
parents | 8cae44c166d3 |
children | 36ae3ec94442 |
comparison
equal
deleted
inserted
replaced
0:8cae44c166d3 | 1:d1400de5832b |
---|---|
1 <?xml version="1.0" encoding="UTF-8"?> | 1 <?xml version="1.0" encoding="UTF-8"?> |
2 <xsl:stylesheet version="1.0" | 2 <xsl:stylesheet version="1.0" |
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | 3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common"> |
4 <xsl:output method="text" /> | 4 <xsl:output method="xml" indent="yes" /> |
5 <xsl:key name="bugs-key" match="bug" use="bug_id" /> | 5 <xsl:key name="bugid" match="bug" use="bug_id" /> |
6 <xsl:variable name="roots" select="bugzilla/bug[not(blocked[key('bugs-key',.)])]"/> | 6 <xsl:variable name="roots" |
7 | 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 <!-- --> | |
8 <xsl:template match="/"> | 68 <xsl:template match="/"> |
9 <xsl:apply-templates select="$roots"/> | 69 <root> |
70 <xsl:copy-of select="$tree" /> | |
71 <xsl:copy-of select="$relations" /> | |
72 <xsl:copy-of select="$structure" /> | |
73 </root> | |
10 </xsl:template> | 74 </xsl:template> |
11 | 75 |
12 <xsl:template match="bug"> | 76 <xsl:template match="bug"> |
13 <xsl:call-template name="bug-template" /> | 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> | |
14 </xsl:template> | 88 </xsl:template> |
15 | 89 |
16 <xsl:template match="text()" /> | 90 <xsl:template match="text()" /> |
17 | 91 |
18 <xsl:template name="bug-template"> | 92 <xsl:template name="bug-template"> |