Mercurial > pub > buggler
comparison bug-list.xsl @ 4:f8f966388b68
xslt: bugzilla -> taskjuggler
| author | cin |
|---|---|
| date | Mon, 24 Aug 2015 20:50:23 +0300 |
| parents | 36ae3ec94442 |
| children | d2efec56373f |
comparison
equal
deleted
inserted
replaced
| 3:36ae3ec94442 | 4:f8f966388b68 |
|---|---|
| 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 extension-element-prefixes="exsl"> |
| 5 <xsl:output method="text" indent="yes" /> | |
| 6 | |
| 7 <xsl:variable name="resources" | |
| 8 select="document('resources.xml')/resources/resource" /> | |
| 9 | |
| 5 <xsl:variable name="bugs" select="/bugzilla/bug" /> | 10 <xsl:variable name="bugs" select="/bugzilla/bug" /> |
| 11 | |
| 6 <xsl:key name="bugid" match="/bugzilla/bug" use="string(bug_id)" /> | 12 <xsl:key name="bugid" match="/bugzilla/bug" use="string(bug_id)" /> |
| 7 <xsl:variable name="roots" | 13 |
| 8 select="$bugs[not(blocked[key('bugid',.)])]" /> | 14 <xsl:variable name="roots" select="$bugs[not(blocked[key('bugid',.)])]" /> |
| 9 | 15 |
| 10 <!-- BUILD BUG TREE --> | 16 <!-- BUILD BUG TREE --> |
| 11 <xsl:variable name="tree"> | 17 <xsl:variable name="tree"> |
| 12 <xsl:apply-templates mode="tree" select="$roots" /> | 18 <xsl:apply-templates mode="tree" select="$roots" /> |
| 13 </xsl:variable> | 19 </xsl:variable> |
| 42 <xsl:variable name="bugid" select="@id" /> | 48 <xsl:variable name="bugid" select="@id" /> |
| 43 <xsl:variable name="path" select="ancestor::bug" /> | 49 <xsl:variable name="path" select="ancestor::bug" /> |
| 44 <xsl:variable name="level" select="count($path)" /> | 50 <xsl:variable name="level" select="count($path)" /> |
| 45 <xsl:for-each select="$path[@product]"> | 51 <xsl:for-each select="$path[@product]"> |
| 46 <xsl:variable name="pos" select="position()" /> | 52 <xsl:variable name="pos" select="position()" /> |
| 47 <xsl:variable name="rank" select="$level - position()" /> | 53 <xsl:variable name="rank" select="$level - $pos" /> |
| 48 <rel container="{@id}" rank="{$rank}" level="{$level}"> | 54 <rel container="{@id}" rank="{$rank}" level="{$level}"> |
| 49 <xsl:for-each select="$path[position() >= $pos]"> | 55 <xsl:for-each select="$path[position() >= $pos and @product]"> |
| 50 <bug id="{@id}" /> | 56 <bug id="{@id}" /> |
| 51 </xsl:for-each> | 57 </xsl:for-each> |
| 52 </rel> | 58 </rel> |
| 53 </xsl:for-each> | 59 </xsl:for-each> |
| 54 </xsl:template> | 60 </xsl:template> |
| 90 </depends> | 96 </depends> |
| 91 </xsl:if> | 97 </xsl:if> |
| 92 </bug> | 98 </bug> |
| 93 </xsl:template> | 99 </xsl:template> |
| 94 | 100 |
| 95 <!-- --> | 101 <!-- output --> |
| 96 <xsl:template match="/"> | 102 <xsl:template match="/"> |
| 97 <root> | 103 <xsl:apply-templates select="exsl:node-set($structure)/bug"> |
| 98 <xsl:copy-of select="$tree" /> | 104 <xsl:with-param name="indent" select="0" /> |
| 99 <xsl:copy-of select="$relations" /> | 105 </xsl:apply-templates> |
| 100 <xsl:copy-of select="$parents" /> | |
| 101 <xsl:copy-of select="$structure" /> | |
| 102 </root> | |
| 103 </xsl:template> | 106 </xsl:template> |
| 104 | 107 |
| 105 <xsl:template match="bug"> | 108 <xsl:template match="bug"> |
| 106 <xsl:value-of select="bug_id" /> | 109 <xsl:param name="indent" select="0" /> |
| 107 <xsl:text>
</xsl:text> | 110 <xsl:variable name="id" select="@id" /> |
| 108 </xsl:template> | 111 <xsl:variable name="details" select="$bugs[bug_id = $id]" /> |
| 109 | 112 <xsl:call-template name="start-task"> |
| 110 <xsl:template match="bug[component = 'product']"> | 113 <xsl:with-param name="indent" select="$indent" /> |
| 111 <xsl:value-of select="bug_id" /> | 114 <xsl:with-param name="id" select="@id" /> |
| 112 <xsl:text>:
</xsl:text> | 115 <xsl:with-param name="desc" select="$details/short_desc" /> |
| 113 <xsl:for-each select="dependson"> | 116 </xsl:call-template> |
| 114 <xsl:apply-templates select="key('bugid', .)" /> | 117 |
| 118 <xsl:for-each select="$details/*"> | |
| 119 <xsl:variable name="directive"> | |
| 120 <xsl:apply-templates select="." mode="task-details" /> | |
| 121 </xsl:variable> | |
| 122 <xsl:if test="string($directive)"> | |
| 123 <xsl:call-template name="begin-line"> | |
| 124 <xsl:with-param name="indent" select="$indent + 1" /> | |
| 125 </xsl:call-template> | |
| 126 <xsl:value-of select="$directive" /> | |
| 127 <xsl:call-template name="end-line" /> | |
| 128 </xsl:if> | |
| 115 </xsl:for-each> | 129 </xsl:for-each> |
| 116 <xsl:text>---END---
</xsl:text> | 130 |
| 117 </xsl:template> | 131 <xsl:apply-templates> |
| 132 <xsl:with-param name="indent" select="$indent + 1" /> | |
| 133 </xsl:apply-templates> | |
| 134 | |
| 135 <xsl:call-template name="end-task"> | |
| 136 <xsl:with-param name="indent" select="$indent" /> | |
| 137 </xsl:call-template> | |
| 138 </xsl:template> | |
| 139 | |
| 140 <xsl:template match="estimated_time" mode="task-details"> | |
| 141 <xsl:if test="number(.)"> | |
| 142 <xsl:value-of select="concat('effort ', .,'h')" /> | |
| 143 </xsl:if> | |
| 144 </xsl:template> | |
| 145 | |
| 146 <xsl:template match="assigned_to" mode="task-details"> | |
| 147 <xsl:variable name="email" select="string(.)" /> | |
| 148 <xsl:variable name="resource" select="$resources[@email = $email]/@id" /> | |
| 149 <xsl:if test="$resource"> | |
| 150 <xsl:value-of select="concat('allocate ', $resource)" /> | |
| 151 </xsl:if> | |
| 152 </xsl:template> | |
| 153 <xsl:template match="text()" mode="task-details"> | |
| 154 </xsl:template> | |
| 155 | |
| 156 <xsl:template match="depends"> | |
| 157 <xsl:param name="indent" select="0" /> | |
| 158 <xsl:call-template name="begin-line"> | |
| 159 <xsl:with-param name="indent" select="$indent" /> | |
| 160 </xsl:call-template> | |
| 161 <xsl:text>depends </xsl:text> | |
| 162 <xsl:apply-templates> | |
| 163 <xsl:with-param name="referer" select=".." /> | |
| 164 </xsl:apply-templates> | |
| 165 <xsl:call-template name="end-line" /> | |
| 166 </xsl:template> | |
| 167 | |
| 168 <xsl:template match="depends/bug"> | |
| 169 <xsl:param name="referer" /> | |
| 170 <xsl:call-template name="bug-reference"> | |
| 171 <xsl:with-param name="id" select="@id" /> | |
| 172 <xsl:with-param name="referer" select="$referer" /> | |
| 173 </xsl:call-template> | |
| 174 <xsl:if test="position() != last()"> | |
| 175 <xsl:text>, </xsl:text> | |
| 176 </xsl:if> | |
| 177 </xsl:template> | |
| 178 | |
| 118 | 179 |
| 119 <xsl:template match="text()" /> | 180 <xsl:template match="text()" /> |
| 120 | 181 |
| 121 <xsl:template name="bug-template"> | 182 |
| 122 <xsl:param name="indent" select="0" /> | 183 |
| 123 <xsl:variable name="isOrganizing" select="component = 'product'"></xsl:variable> | 184 <xsl:template name="bug-local-name"> |
| 124 | 185 <xsl:param name="id" /> |
| 125 <xsl:call-template name="start-task"> | 186 <xsl:value-of select="concat('bug',$id)" /> |
| 126 <xsl:with-param name="indent" select="$indent" /> | 187 </xsl:template> |
| 127 </xsl:call-template> | 188 |
| 128 | 189 |
| 129 <xsl:if test="$isOrganizing"> | 190 <xsl:template name="bug-reference"> |
| 130 | 191 <xsl:param name="id" /> |
| 131 </xsl:if> | 192 <xsl:param name="referer" /> |
| 132 | 193 |
| 133 <xsl:choose> | 194 <xsl:variable name="refererPathFragment"> |
| 134 <xsl:when test="$isOrganizing"> | 195 <bug id="#root" /> |
| 135 <xsl:for-each select="dependson"> | 196 <xsl:for-each select="$referer/ancestor-or-self::bug"> |
| 136 <xsl:for-each select="key('bugs-key', .)"> | 197 <bug id="{@id}" /> |
| 137 <xsl:call-template name="bug-template"> | 198 </xsl:for-each> |
| 138 <xsl:with-param name="indent" select="$indent + 1" /> | 199 </xsl:variable> |
| 139 </xsl:call-template> | 200 <xsl:variable name="targetPathFragment"> |
| 140 </xsl:for-each> | 201 <bug id="#root" /> |
| 141 </xsl:for-each> | 202 <xsl:for-each |
| 142 </xsl:when> | 203 select="exsl:node-set($structure)//bug[local-name(..) != 'depends' and @id = $id]/ancestor-or-self::bug"> |
| 143 <xsl:otherwise> | 204 <bug id="{@id}" /> |
| 144 <xsl:if test="number(estimated_time)"> | 205 </xsl:for-each> |
| 145 <xsl:call-template name="begin-line"> | 206 </xsl:variable> |
| 146 <xsl:with-param name="indent" select="$indent + 1" /> | 207 <xsl:variable name="path" |
| 147 </xsl:call-template> | 208 select="exsl:node-set($refererPathFragment)/bug" /> |
| 148 <xsl:value-of select="concat('effort ', estimated_time, 'h')" /> | 209 <xsl:variable name="targetPath" |
| 149 <xsl:call-template name="end-line" /> | 210 select="exsl:node-set($targetPathFragment)/bug" /> |
| 150 </xsl:if> | 211 |
| 151 </xsl:otherwise> | 212 <!-- find closest shared container id --> |
| 152 </xsl:choose> | 213 <xsl:variable name="join" |
| 153 | 214 select="($path[@id = $targetPath/@id])[position() = last() ]/@id" /> |
| 154 <xsl:call-template name="end-task"> | 215 |
| 155 <xsl:with-param name="indent" select="$indent" /> | 216 <!-- how many levels we need to up --> |
| 156 </xsl:call-template> | 217 <xsl:variable name="depth" |
| 157 </xsl:template> | 218 select="count($path[@id = $join]/following-sibling::node())" /> |
| 158 | 219 |
| 159 <xsl:template name="make-bug-id"> | 220 <!-- DEBUG --> |
| 160 <xsl:param name="id"></xsl:param> | 221 <!-- <xsl:value-of select="concat('id=', $id, ',referer=', $referer/@id)" |
| 161 <xsl:value-of select="concat('bug', $id)"></xsl:value-of> | 222 /> <xsl:text>, path=</xsl:text> <xsl:for-each select="$targetPath"> <xsl:value-of |
| 223 select="concat(name(),@id)" /> <xsl:if test="position() != last()"> <xsl:text>-</xsl:text> | |
| 224 </xsl:if> </xsl:for-each> --> | |
| 225 <!-- DEBUG --> | |
| 226 <!-- <xsl:value-of select="concat(', join=', $join,', depth=', $depth,' | |
| 227 ')" /> --> | |
| 228 | |
| 229 <!-- PRINT REFERENCE --> | |
| 230 <xsl:call-template name="repeat"> | |
| 231 <xsl:with-param name="value" select="'!'" /> | |
| 232 <xsl:with-param name="count" select="$depth" /> | |
| 233 </xsl:call-template> | |
| 234 <xsl:for-each select="$targetPath[@id = $join]/following-sibling::node()"> | |
| 235 <xsl:call-template name="bug-local-name"> | |
| 236 <xsl:with-param name="id" select="@id" /> | |
| 237 </xsl:call-template> | |
| 238 <xsl:if test="position() != last()"> | |
| 239 <xsl:text>.</xsl:text> | |
| 240 </xsl:if> | |
| 241 </xsl:for-each> | |
| 242 | |
| 162 </xsl:template> | 243 </xsl:template> |
| 163 | 244 |
| 164 <xsl:template name="start-task"> | 245 <xsl:template name="start-task"> |
| 165 <xsl:param name="indent" /> | 246 <xsl:param name="indent" /> |
| 247 <xsl:param name="id" /> | |
| 248 <xsl:param name="desc" /> | |
| 166 <xsl:call-template name="begin-line"> | 249 <xsl:call-template name="begin-line"> |
| 167 <xsl:with-param name="indent" select="$indent" /> | 250 <xsl:with-param name="indent" select="$indent" /> |
| 168 </xsl:call-template> | 251 </xsl:call-template> |
| 169 <xsl:text>task </xsl:text> | 252 <xsl:text>task </xsl:text> |
| 170 <xsl:call-template name="make-bug-id"> | 253 <xsl:call-template name="bug-local-name"> |
| 171 <xsl:with-param name="id" select="bug_id" /> | 254 <xsl:with-param name="id" select="$id" /> |
| 172 </xsl:call-template> | 255 </xsl:call-template> |
| 173 <xsl:value-of select="concat(' "',short_desc,'" {')" /> | 256 <xsl:value-of select="concat(' "',$desc,'" {')" /> |
| 174 <xsl:call-template name="end-line" /> | 257 <xsl:call-template name="end-line" /> |
| 175 </xsl:template> | 258 </xsl:template> |
| 176 | 259 |
| 177 <xsl:template name="end-task"> | 260 <xsl:template name="end-task"> |
| 178 <xsl:param name="indent" /> | 261 <xsl:param name="indent" /> |
| 193 </xsl:if> | 276 </xsl:if> |
| 194 </xsl:template> | 277 </xsl:template> |
| 195 <xsl:template name="end-line"> | 278 <xsl:template name="end-line"> |
| 196 <xsl:text>
</xsl:text> | 279 <xsl:text>
</xsl:text> |
| 197 </xsl:template> | 280 </xsl:template> |
| 281 | |
| 282 <xsl:template name="repeat"> | |
| 283 <xsl:param name="value" /> | |
| 284 <xsl:param name="count" select="0" /> | |
| 285 | |
| 286 <xsl:if test="number($count)"> | |
| 287 <xsl:copy-of select="$value" /> | |
| 288 <xsl:call-template name="repeat"> | |
| 289 <xsl:with-param name="value" select="$value" /> | |
| 290 <xsl:with-param name="count" select="$count - 1" /> | |
| 291 </xsl:call-template> | |
| 292 </xsl:if> | |
| 293 </xsl:template> | |
| 198 </xsl:stylesheet> | 294 </xsl:stylesheet> |
