Mercurial > pub > buggler
comparison bug-list.xsl @ 3:36ae3ec94442
xslt: prepare taskjuggler tasks structure
| author | cin |
|---|---|
| date | Mon, 24 Aug 2015 10:16:41 +0300 |
| parents | d1400de5832b |
| children | f8f966388b68 |
comparison
equal
deleted
inserted
replaced
| 2:14caabdb946b | 3:36ae3ec94442 |
|---|---|
| 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" xmlns:exsl="http://exslt.org/common"> | 3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common"> |
| 4 <xsl:output method="xml" indent="yes" /> | 4 <xsl:output method="xml" indent="yes" /> |
| 5 <xsl:key name="bugid" match="bug" use="bug_id" /> | 5 <xsl:variable name="bugs" select="/bugzilla/bug" /> |
| 6 <xsl:key name="bugid" match="/bugzilla/bug" use="string(bug_id)" /> | |
| 6 <xsl:variable name="roots" | 7 <xsl:variable name="roots" |
| 7 select="bugzilla/bug[not(blocked[key('bugid',.)])]" /> | 8 select="$bugs[not(blocked[key('bugid',.)])]" /> |
| 8 | 9 |
| 9 <!-- BUILD BUG TREE --> | 10 <!-- BUILD BUG TREE --> |
| 10 <xsl:variable name="tree"> | 11 <xsl:variable name="tree"> |
| 11 <xsl:apply-templates mode="tree" select="$roots" /> | 12 <xsl:apply-templates mode="tree" select="$roots" /> |
| 12 </xsl:variable> | 13 </xsl:variable> |
| 13 | 14 |
| 14 <xsl:template match="bug" mode="tree"> | 15 <xsl:template match="bug" mode="tree"> |
| 15 <xsl:element name="bug"> | 16 <xsl:element name="bug"> |
| 16 <xsl:attribute name="id"><xsl:value-of select="bug_id" /></xsl:attribute> | 17 <xsl:attribute name="id"><xsl:value-of select="bug_id" /></xsl:attribute> |
| 17 <xsl:if test="component = 'product'"> | 18 <xsl:if test="component = 'product' or not(number(estimated_time))"> |
| 18 <xsl:attribute name="product"><xsl:value-of select="boolean(1)" /></xsl:attribute> | 19 <xsl:attribute name="product"><xsl:value-of select="boolean(1)" /></xsl:attribute> |
| 19 </xsl:if> | 20 </xsl:if> |
| 20 <xsl:for-each select="dependson"> | 21 <xsl:for-each select="dependson"> |
| 21 <xsl:apply-templates mode="tree" select="key('bugid', .)" /> | 22 <xsl:apply-templates mode="tree" select="key('bugid', .)" /> |
| 22 </xsl:for-each> | 23 </xsl:for-each> |
| 23 </xsl:element> | 24 </xsl:element> |
| 24 </xsl:template> | 25 </xsl:template> |
| 25 | 26 |
| 26 <!-- CALCULATE RELATIONS --> | 27 <!-- CALCULATE RELATIONS --> |
| 27 <xsl:variable name="relations"> | 28 <xsl:variable name="relations"> |
| 28 <xsl:apply-templates select="bugzilla/bug" mode="relations" /> | 29 <xsl:apply-templates select="$bugs" mode="relations" /> |
| 29 </xsl:variable> | 30 </xsl:variable> |
| 30 | 31 |
| 31 <xsl:template match="bug" mode="relations"> | 32 <xsl:template match="bug" mode="relations"> |
| 32 <xsl:variable name="bugid" select="string(bug_id)" /> | 33 <xsl:variable name="bugid" select="string(bug_id)" /> |
| 33 <bug id="{$bugid}"> | 34 <bug id="{$bugid}"> |
| 37 </bug> | 38 </bug> |
| 38 </xsl:template> | 39 </xsl:template> |
| 39 | 40 |
| 40 <xsl:template match="bug" mode="traverse-relations"> | 41 <xsl:template match="bug" mode="traverse-relations"> |
| 41 <xsl:variable name="bugid" select="@id" /> | 42 <xsl:variable name="bugid" select="@id" /> |
| 42 <xsl:variable name="level" select="count(ancestor::node())" /> | 43 <xsl:variable name="path" select="ancestor::bug" /> |
| 43 <path> | 44 <xsl:variable name="level" select="count($path)" /> |
| 44 <xsl:for-each select="ancestor::node()"> | 45 <xsl:for-each select="$path[@product]"> |
| 45 <bug id="{@id}" product="{@product}"/> | 46 <xsl:variable name="pos" select="position()" /> |
| 46 </xsl:for-each> | |
| 47 </path> | |
| 48 <xsl:for-each select="ancestor::bug[@product]"> | |
| 49 <xsl:variable name="rank" select="$level - position()" /> | 47 <xsl:variable name="rank" select="$level - position()" /> |
| 50 <rel container="{@id}" rank="{$rank}" level="{$level}"/> | 48 <rel container="{@id}" rank="{$rank}" level="{$level}"> |
| 49 <xsl:for-each select="$path[position() >= $pos]"> | |
| 50 <bug id="{@id}" /> | |
| 51 </xsl:for-each> | |
| 52 </rel> | |
| 51 </xsl:for-each> | 53 </xsl:for-each> |
| 52 </xsl:template> | 54 </xsl:template> |
| 53 | 55 |
| 54 <!-- CALCULATE STRUCTURE --> | 56 <!-- CALCULATE STRUCTURE --> |
| 55 | 57 |
| 58 <xsl:variable name="parents"> | |
| 59 <xsl:apply-templates select="exsl:node-set($relations)" | |
| 60 mode="parents" /> | |
| 61 </xsl:variable> | |
| 62 | |
| 63 <xsl:template match="bug" mode="parents"> | |
| 64 <xsl:variable name="parent" | |
| 65 select="rel[ not(../rel/@rank < @rank) ][1]" /> | |
| 66 <bug id="{@id}" parent="{$parent/@container}" rank="{$parent/@rank}" | |
| 67 level="{$parent/@level}" /> | |
| 68 </xsl:template> | |
| 69 | |
| 56 <xsl:variable name="structure"> | 70 <xsl:variable name="structure"> |
| 57 <xsl:apply-templates select="exsl:node-set($relations)" | 71 <xsl:apply-templates select="$roots" mode="structure" /> |
| 58 mode="structure" /> | |
| 59 </xsl:variable> | 72 </xsl:variable> |
| 60 | 73 |
| 61 <xsl:template match="bug" mode="structure"> | 74 <xsl:template match="bug" mode="structure"> |
| 62 <xsl:variable name="parent" | 75 <xsl:variable name="id" select="string(bug_id)" /> |
| 63 select="rel[ not(../rel/@rank < @rank) ][1]/@container" /> | 76 <xsl:variable name="self" select="." /> |
| 64 <bug id="{@id}" container="{$parent}" /> | 77 <bug id="{$id}"> |
| 78 <xsl:for-each select="exsl:node-set($parents)/bug[@parent = $id]"> | |
| 79 <xsl:variable name="child" select="@id" /> | |
| 80 <xsl:apply-templates select="$bugs[bug_id = $child]" | |
| 81 mode="structure" /> | |
| 82 </xsl:for-each> | |
| 83 <xsl:variable name="dependencies" | |
| 84 select="dependson[not(text() = exsl:node-set($parents)/bug[@parent = $id]/@id)]" /> | |
| 85 <xsl:if test="$dependencies"> | |
| 86 <depends> | |
| 87 <xsl:for-each select="$dependencies"> | |
| 88 <bug id="{.}" /> | |
| 89 </xsl:for-each> | |
| 90 </depends> | |
| 91 </xsl:if> | |
| 92 </bug> | |
| 65 </xsl:template> | 93 </xsl:template> |
| 66 | 94 |
| 67 <!-- --> | 95 <!-- --> |
| 68 <xsl:template match="/"> | 96 <xsl:template match="/"> |
| 69 <root> | 97 <root> |
| 70 <xsl:copy-of select="$tree" /> | 98 <xsl:copy-of select="$tree" /> |
| 71 <xsl:copy-of select="$relations" /> | 99 <xsl:copy-of select="$relations" /> |
| 100 <xsl:copy-of select="$parents" /> | |
| 72 <xsl:copy-of select="$structure" /> | 101 <xsl:copy-of select="$structure" /> |
| 73 </root> | 102 </root> |
| 74 </xsl:template> | 103 </xsl:template> |
| 75 | 104 |
| 76 <xsl:template match="bug"> | 105 <xsl:template match="bug"> |
