Mercurial > pub > buggler
comparison bug-list.xsl @ 6:2a5f38eb25a9
migrated to saxon8 as xslt processor
fixed dependency calculation when a container has a dependency on his grandchild
| author | cin |
|---|---|
| date | Wed, 02 Sep 2015 20:43:38 +0300 |
| parents | d2efec56373f |
| children | 14a966369278 |
comparison
equal
deleted
inserted
replaced
| 5:d2efec56373f | 6:2a5f38eb25a9 |
|---|---|
| 49 </xsl:variable> | 49 </xsl:variable> |
| 50 | 50 |
| 51 <xsl:template match="bug" mode="relations"> | 51 <xsl:template match="bug" mode="relations"> |
| 52 <xsl:variable name="bugid" select="string(bug_id)" /> | 52 <xsl:variable name="bugid" select="string(bug_id)" /> |
| 53 <bug id="{$bugid}"> | 53 <bug id="{$bugid}"> |
| 54 <!-- calculate all palaces where the same node appears --> | |
| 54 <xsl:apply-templates select="exsl:node-set($tree)//bug[@id = $bugid]" | 55 <xsl:apply-templates select="exsl:node-set($tree)//bug[@id = $bugid]" |
| 55 mode="traverse-relations"> | 56 mode="traverse-relations"> |
| 56 </xsl:apply-templates> | 57 </xsl:apply-templates> |
| 57 </bug> | 58 </bug> |
| 58 </xsl:template> | 59 </xsl:template> |
| 59 | 60 |
| 60 <xsl:template match="bug" mode="traverse-relations"> | 61 <xsl:template match="bug" mode="traverse-relations"> |
| 61 <xsl:variable name="bugid" select="@id" /> | 62 <xsl:variable name="bugid" select="@id" /> |
| 62 <xsl:variable name="path" select="ancestor::bug" /> | 63 <xsl:variable name="path" select="ancestor::bug" /> |
| 63 <xsl:variable name="level" select="count($path)" /> | 64 <xsl:variable name="level" select="count($path)" /> |
| 65 <!-- for the specified path calculate the distances to the preceding container --> | |
| 64 <xsl:for-each select="$path[@group]"> | 66 <xsl:for-each select="$path[@group]"> |
| 65 <xsl:variable name="pos" select="position()" /> | 67 <xsl:variable name="pos" select="position()" /> |
| 66 <xsl:variable name="rank" select="$level - $pos" /> | 68 <xsl:variable name="rank" select="$level - $pos" /> |
| 67 <rel container="{@id}" rank="{$rank}" level="{$level}"> | 69 <rel container="{@id}" rank="{$rank}" level="{$level}"> |
| 68 <xsl:for-each select="$path[position() >= $pos and @group]"> | 70 <!-- record the full path --> |
| 69 <bug id="{@id}" /> | 71 <xsl:for-each select="$path[@group]"> |
| 72 <parent id="{@id}" bugid="{$bugid}" /> | |
| 70 </xsl:for-each> | 73 </xsl:for-each> |
| 71 </rel> | 74 </rel> |
| 72 </xsl:for-each> | 75 </xsl:for-each> |
| 73 </xsl:template> | 76 </xsl:template> |
| 74 | 77 |
| 81 | 84 |
| 82 <xsl:template match="bug" mode="parents"> | 85 <xsl:template match="bug" mode="parents"> |
| 83 <xsl:variable name="parent" | 86 <xsl:variable name="parent" |
| 84 select="rel[ not(../rel/@rank < @rank) ][1]" /> | 87 select="rel[ not(../rel/@rank < @rank) ][1]" /> |
| 85 <bug id="{@id}" parent="{$parent/@container}" rank="{$parent/@rank}" | 88 <bug id="{@id}" parent="{$parent/@container}" rank="{$parent/@rank}" |
| 86 level="{$parent/@level}" /> | 89 level="{$parent/@level}"> |
| 90 <xsl:copy-of select="$parent/node()" /> | |
| 91 </bug> | |
| 87 </xsl:template> | 92 </xsl:template> |
| 88 | 93 |
| 89 <xsl:variable name="structure"> | 94 <xsl:variable name="structure"> |
| 90 <xsl:choose> | 95 <xsl:choose> |
| 91 <xsl:when test="$root_task"> | 96 <xsl:when test="$root_task"> |
| 92 <bug id="_root" desc="{$root_task}" group="true"> | 97 <bug id="_root" desc="{$root_task}" group="true"> |
| 93 <xsl:apply-templates select="$roots" mode="structure"/> | 98 <xsl:apply-templates select="$roots" mode="structure" /> |
| 94 </bug> | 99 </bug> |
| 95 </xsl:when> | 100 </xsl:when> |
| 96 <xsl:otherwise> | 101 <xsl:otherwise> |
| 97 <xsl:apply-templates select="$roots" mode="structure"/> | 102 <xsl:apply-templates select="$roots" mode="structure" /> |
| 98 </xsl:otherwise> | 103 </xsl:otherwise> |
| 99 </xsl:choose> | 104 </xsl:choose> |
| 100 </xsl:variable> | 105 </xsl:variable> |
| 101 | 106 |
| 107 <!-- applied in context of the bugzilla document --> | |
| 102 <xsl:template match="bug" mode="structure"> | 108 <xsl:template match="bug" mode="structure"> |
| 103 <xsl:variable name="id" select="string(bug_id)" /> | 109 <xsl:variable name="id" select="string(bug_id)" /> |
| 104 <xsl:variable name="self" select="." /> | 110 <xsl:variable name="self" select="." /> |
| 105 <xsl:variable name="children" | 111 <xsl:variable name="children" |
| 106 select="exsl:node-set($parents)/bug[@parent = $id]" /> | 112 select="exsl:node-set($parents)/bug[@parent = $id]" /> |
| 118 </xsl:for-each> | 124 </xsl:for-each> |
| 119 | 125 |
| 120 </xsl:if> | 126 </xsl:if> |
| 121 | 127 |
| 122 <!-- filter out dependencies --> | 128 <!-- filter out dependencies --> |
| 129 <!-- exclude children, and missing bugs --> | |
| 123 <xsl:variable name="dependencies" | 130 <xsl:variable name="dependencies" |
| 124 select="dependson[not(text() = exsl:node-set($parents)/bug[@parent = $id]/@id)]" /> | 131 select="dependson[not(text() = exsl:node-set($parents)/bug/parent[@id=$id]/@bugid)][key('bugid', .)]" /> |
| 125 <xsl:for-each select="$dependencies"> | 132 <xsl:for-each select="$dependencies"> |
| 126 <dependency id="{.}" /> | 133 <dependency id="{.}" /> |
| 127 </xsl:for-each> | 134 </xsl:for-each> |
| 128 </xsl:element> | 135 </xsl:element> |
| 129 </xsl:template> | 136 </xsl:template> |
| 130 | 137 |
| 131 <!-- output --> | 138 <!-- output --> |
| 132 <xsl:template match="/"> | 139 <xsl:template match="/"> |
| 133 <xsl:apply-templates select="exsl:node-set($structure)/bug"> | 140 <xsl:apply-templates select="exsl:node-set($structure)/bug"> |
| 134 <xsl:with-param name="indent" select="0" /> | 141 <xsl:with-param name="indent" select="0" /> |
| 135 <xsl:with-param name="chargeset" select="$chargeset"/> | 142 <xsl:with-param name="chargeset" select="$chargeset" /> |
| 136 </xsl:apply-templates> | 143 </xsl:apply-templates> |
| 137 </xsl:template> | 144 </xsl:template> |
| 138 | 145 |
| 139 <xsl:template match="bug"> | 146 <xsl:template match="bug"> |
| 140 <xsl:param name="indent" select="0" /> | 147 <xsl:param name="indent" select="0" /> |
| 141 <xsl:param name="chargeset" /> | 148 <xsl:param name="chargeset" /> |
| 142 <xsl:variable name="id" select="@id" /> | 149 <xsl:variable name="id" select="@id" /> |
| 143 <xsl:variable name="details" select="$bugs[bug_id = $id]" /> | 150 <xsl:variable name="details" select="$bugs[bug_id = $id]" /> |
| 151 <xsl:variable name="hasTime" | |
| 152 select="number($details/estimated_time) or number($details/actual_time) or number($details/remaining_time)" /> | |
| 144 | 153 |
| 145 <!-- task header --> | 154 <!-- task header --> |
| 146 <xsl:call-template name="start-task"> | 155 <xsl:call-template name="start-task"> |
| 147 <xsl:with-param name="indent" select="$indent" /> | 156 <xsl:with-param name="indent" select="$indent" /> |
| 148 <xsl:with-param name="id"> | 157 <xsl:with-param name="id"> |
| 150 <xsl:with-param name="id" select="@id" /> | 159 <xsl:with-param name="id" select="@id" /> |
| 151 </xsl:call-template> | 160 </xsl:call-template> |
| 152 </xsl:with-param> | 161 </xsl:with-param> |
| 153 <xsl:with-param name="desc" select="@desc" /> | 162 <xsl:with-param name="desc" select="@desc" /> |
| 154 </xsl:call-template> | 163 </xsl:call-template> |
| 155 | 164 |
| 156 <xsl:if test="$chargeset"> | 165 <xsl:if test="$chargeset"> |
| 157 <xsl:call-template name="println"> | 166 <xsl:call-template name="println"> |
| 158 <xsl:with-param name="indent" select="$indent + 1"/> | 167 <xsl:with-param name="indent" select="$indent + 1" /> |
| 159 <xsl:with-param name="text" select="concat('chargeset ', $chargeset)"/> | 168 <xsl:with-param name="text" |
| 169 select="concat('chargeset ', $chargeset)" /> | |
| 160 </xsl:call-template> | 170 </xsl:call-template> |
| 161 </xsl:if> | 171 </xsl:if> |
| 162 | 172 |
| 163 <!-- task details --> | 173 <!-- task details --> |
| 164 <xsl:choose> | 174 <xsl:choose> |
| 173 <xsl:apply-templates select="$details/node()" | 183 <xsl:apply-templates select="$details/node()" |
| 174 mode="group-details"> | 184 mode="group-details"> |
| 175 <xsl:with-param name="indent" select="$indent + 1" /> | 185 <xsl:with-param name="indent" select="$indent + 1" /> |
| 176 </xsl:apply-templates> | 186 </xsl:apply-templates> |
| 177 | 187 |
| 178 <xsl:if | 188 <xsl:if test="$hasTime"> |
| 179 test="number($details/estimated_time) or number($details/actual_time) or number($details/remaining_time)"> | |
| 180 <xsl:call-template name="start-task"> | 189 <xsl:call-template name="start-task"> |
| 181 <xsl:with-param name="indent" select="$indent + 1" /> | 190 <xsl:with-param name="indent" select="$indent + 1" /> |
| 182 <xsl:with-param name="id" select="'manage'" /> | 191 <xsl:with-param name="id" select="'manage'" /> |
| 183 <xsl:with-param name="desc" select="@desc" /> | 192 <xsl:with-param name="desc" select="@desc" /> |
| 184 </xsl:call-template> | 193 </xsl:call-template> |
| 185 <xsl:apply-templates | 194 <xsl:apply-templates |
| 186 select="$details/estimated_time | $details/actual_time | $details/remaining_time | $details/assigned_to" | 195 select="$details/estimated_time | $details/actual_time | $details/remaining_time | $details/assigned_to" |
| 187 mode="task-details"> | 196 mode="task-details"> |
| 188 <xsl:with-param name="indent" select="$indent + 2" /> | 197 <xsl:with-param name="indent" select="$indent + 2" /> |
| 198 <xsl:with-param name="hasTime" select="$hasTime" /> | |
| 189 </xsl:apply-templates> | 199 </xsl:apply-templates> |
| 190 <xsl:call-template name="end-task"> | 200 <xsl:call-template name="end-task"> |
| 191 <xsl:with-param name="indent" select="$indent + 1" /> | 201 <xsl:with-param name="indent" select="$indent + 1" /> |
| 192 </xsl:call-template> | 202 </xsl:call-template> |
| 193 </xsl:if> | 203 </xsl:if> |
| 194 </xsl:when> | 204 </xsl:when> |
| 195 <xsl:otherwise> | 205 <xsl:otherwise> |
| 196 <xsl:apply-templates select="$details/node()" | 206 <xsl:apply-templates select="$details/node()" |
| 197 mode="task-details"> | 207 mode="task-details"> |
| 198 <xsl:with-param name="indent" select="$indent + 1" /> | 208 <xsl:with-param name="indent" select="$indent + 1" /> |
| 209 <xsl:with-param name="hasTime" select="$hasTime" /> | |
| 199 </xsl:apply-templates> | 210 </xsl:apply-templates> |
| 200 </xsl:otherwise> | 211 </xsl:otherwise> |
| 201 </xsl:choose> | 212 </xsl:choose> |
| 202 | 213 |
| 203 <!-- subtasks and dependencies --> | 214 <!-- subtasks and dependencies --> |
| 241 </xsl:if> | 252 </xsl:if> |
| 242 </xsl:template> | 253 </xsl:template> |
| 243 | 254 |
| 244 <xsl:template match="assigned_to" mode="task-details"> | 255 <xsl:template match="assigned_to" mode="task-details"> |
| 245 <xsl:param name="indent" /> | 256 <xsl:param name="indent" /> |
| 246 <xsl:variable name="email" select="string(.)" /> | 257 <xsl:param name="hasTime" /> |
| 247 <xsl:variable name="resource" select="$resources[@email = $email]/@id" /> | 258 <xsl:if test="$hasTime"> |
| 248 <xsl:if test="$resource"> | 259 <xsl:variable name="email" select="string(.)" /> |
| 249 <xsl:call-template name="println"> | 260 <xsl:variable name="resource" select="$resources[@email = $email]/@id" /> |
| 250 <xsl:with-param name="indent" select="$indent" /> | 261 <xsl:if test="$resource"> |
| 251 <xsl:with-param name="text" select="concat('allocate ', $resource)" /> | 262 <xsl:call-template name="println"> |
| 252 </xsl:call-template> | 263 <xsl:with-param name="indent" select="$indent" /> |
| 264 <xsl:with-param name="text" | |
| 265 select="concat('allocate ', $resource)" /> | |
| 266 </xsl:call-template> | |
| 267 </xsl:if> | |
| 253 </xsl:if> | 268 </xsl:if> |
| 254 </xsl:template> | 269 </xsl:template> |
| 255 <xsl:template match="text()" mode="task-details"> | 270 <xsl:template match="text()" mode="task-details"> |
| 256 </xsl:template> | 271 </xsl:template> |
| 257 | 272 |
| 374 <xsl:template name="repeat"> | 389 <xsl:template name="repeat"> |
| 375 <xsl:param name="value" /> | 390 <xsl:param name="value" /> |
| 376 <xsl:param name="count" select="0" /> | 391 <xsl:param name="count" select="0" /> |
| 377 | 392 |
| 378 <xsl:if test="number($count)"> | 393 <xsl:if test="number($count)"> |
| 379 <xsl:copy-of select="$value" /> | 394 <xsl:value-of select="$value" /> |
| 380 <xsl:call-template name="repeat"> | 395 <xsl:call-template name="repeat"> |
| 381 <xsl:with-param name="value" select="$value" /> | 396 <xsl:with-param name="value" select="$value" /> |
| 382 <xsl:with-param name="count" select="$count - 1" /> | 397 <xsl:with-param name="count" select="$count - 1" /> |
| 383 </xsl:call-template> | 398 </xsl:call-template> |
| 384 </xsl:if> | 399 </xsl:if> |
