Mercurial > pub > buggler
changeset 3:36ae3ec94442
xslt: prepare taskjuggler tasks structure
author | cin |
---|---|
date | Mon, 24 Aug 2015 10:16:41 +0300 |
parents | 14caabdb946b |
children | f8f966388b68 |
files | bug-list.xsl |
diffstat | 1 files changed, 46 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/bug-list.xsl Fri Aug 21 20:08:24 2015 +0300 +++ b/bug-list.xsl Mon Aug 24 10:16:41 2015 +0300 @@ -2,9 +2,10 @@ <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common"> <xsl:output method="xml" indent="yes" /> - <xsl:key name="bugid" match="bug" use="bug_id" /> + <xsl:variable name="bugs" select="/bugzilla/bug" /> + <xsl:key name="bugid" match="/bugzilla/bug" use="string(bug_id)" /> <xsl:variable name="roots" - select="bugzilla/bug[not(blocked[key('bugid',.)])]" /> + select="$bugs[not(blocked[key('bugid',.)])]" /> <!-- BUILD BUG TREE --> <xsl:variable name="tree"> @@ -14,7 +15,7 @@ <xsl:template match="bug" mode="tree"> <xsl:element name="bug"> <xsl:attribute name="id"><xsl:value-of select="bug_id" /></xsl:attribute> - <xsl:if test="component = 'product'"> + <xsl:if test="component = 'product' or not(number(estimated_time))"> <xsl:attribute name="product"><xsl:value-of select="boolean(1)" /></xsl:attribute> </xsl:if> <xsl:for-each select="dependson"> @@ -25,7 +26,7 @@ <!-- CALCULATE RELATIONS --> <xsl:variable name="relations"> - <xsl:apply-templates select="bugzilla/bug" mode="relations" /> + <xsl:apply-templates select="$bugs" mode="relations" /> </xsl:variable> <xsl:template match="bug" mode="relations"> @@ -39,29 +40,56 @@ <xsl:template match="bug" mode="traverse-relations"> <xsl:variable name="bugid" select="@id" /> - <xsl:variable name="level" select="count(ancestor::node())" /> - <path> - <xsl:for-each select="ancestor::node()"> - <bug id="{@id}" product="{@product}"/> - </xsl:for-each> - </path> - <xsl:for-each select="ancestor::bug[@product]"> + <xsl:variable name="path" select="ancestor::bug" /> + <xsl:variable name="level" select="count($path)" /> + <xsl:for-each select="$path[@product]"> + <xsl:variable name="pos" select="position()" /> <xsl:variable name="rank" select="$level - position()" /> - <rel container="{@id}" rank="{$rank}" level="{$level}"/> + <rel container="{@id}" rank="{$rank}" level="{$level}"> + <xsl:for-each select="$path[position() >= $pos]"> + <bug id="{@id}" /> + </xsl:for-each> + </rel> </xsl:for-each> </xsl:template> <!-- CALCULATE STRUCTURE --> - <xsl:variable name="structure"> + <xsl:variable name="parents"> <xsl:apply-templates select="exsl:node-set($relations)" - mode="structure" /> + mode="parents" /> + </xsl:variable> + + <xsl:template match="bug" mode="parents"> + <xsl:variable name="parent" + select="rel[ not(../rel/@rank < @rank) ][1]" /> + <bug id="{@id}" parent="{$parent/@container}" rank="{$parent/@rank}" + level="{$parent/@level}" /> + </xsl:template> + + <xsl:variable name="structure"> + <xsl:apply-templates select="$roots" mode="structure" /> </xsl:variable> <xsl:template match="bug" mode="structure"> - <xsl:variable name="parent" - select="rel[ not(../rel/@rank < @rank) ][1]/@container" /> - <bug id="{@id}" container="{$parent}" /> + <xsl:variable name="id" select="string(bug_id)" /> + <xsl:variable name="self" select="." /> + <bug id="{$id}"> + <xsl:for-each select="exsl:node-set($parents)/bug[@parent = $id]"> + <xsl:variable name="child" select="@id" /> + <xsl:apply-templates select="$bugs[bug_id = $child]" + mode="structure" /> + </xsl:for-each> + <xsl:variable name="dependencies" + select="dependson[not(text() = exsl:node-set($parents)/bug[@parent = $id]/@id)]" /> + <xsl:if test="$dependencies"> + <depends> + <xsl:for-each select="$dependencies"> + <bug id="{.}" /> + </xsl:for-each> + </depends> + </xsl:if> + </bug> </xsl:template> <!-- --> @@ -69,6 +97,7 @@ <root> <xsl:copy-of select="$tree" /> <xsl:copy-of select="$relations" /> + <xsl:copy-of select="$parents" /> <xsl:copy-of select="$structure" /> </root> </xsl:template>