diff 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
line wrap: on
line diff
--- a/bug-list.xsl	Tue Sep 01 19:47:30 2015 +0300
+++ b/bug-list.xsl	Wed Sep 02 20:43:38 2015 +0300
@@ -51,6 +51,7 @@
 	<xsl:template match="bug" mode="relations">
 		<xsl:variable name="bugid" select="string(bug_id)" />
 		<bug id="{$bugid}">
+			<!-- calculate all palaces where the same node appears -->
 			<xsl:apply-templates select="exsl:node-set($tree)//bug[@id = $bugid]"
 				mode="traverse-relations">
 			</xsl:apply-templates>
@@ -61,12 +62,14 @@
 		<xsl:variable name="bugid" select="@id" />
 		<xsl:variable name="path" select="ancestor::bug" />
 		<xsl:variable name="level" select="count($path)" />
+		<!-- for the specified path calculate the distances to the preceding container -->
 		<xsl:for-each select="$path[@group]">
 			<xsl:variable name="pos" select="position()" />
 			<xsl:variable name="rank" select="$level - $pos" />
 			<rel container="{@id}" rank="{$rank}" level="{$level}">
-				<xsl:for-each select="$path[position() >= $pos and @group]">
-					<bug id="{@id}" />
+				<!-- record the full path -->
+				<xsl:for-each select="$path[@group]">
+					<parent id="{@id}" bugid="{$bugid}" />
 				</xsl:for-each>
 			</rel>
 		</xsl:for-each>
@@ -83,22 +86,25 @@
 		<xsl:variable name="parent"
 			select="rel[ not(../rel/@rank &lt; @rank) ][1]" />
 		<bug id="{@id}" parent="{$parent/@container}" rank="{$parent/@rank}"
-			level="{$parent/@level}" />
+			level="{$parent/@level}">
+			<xsl:copy-of select="$parent/node()" />
+		</bug>
 	</xsl:template>
 
 	<xsl:variable name="structure">
 		<xsl:choose>
 			<xsl:when test="$root_task">
 				<bug id="_root" desc="{$root_task}" group="true">
-					<xsl:apply-templates select="$roots" mode="structure"/>
+					<xsl:apply-templates select="$roots" mode="structure" />
 				</bug>
 			</xsl:when>
 			<xsl:otherwise>
-				<xsl:apply-templates select="$roots" mode="structure"/>
+				<xsl:apply-templates select="$roots" mode="structure" />
 			</xsl:otherwise>
 		</xsl:choose>
 	</xsl:variable>
 
+	<!-- applied in context of the bugzilla document -->
 	<xsl:template match="bug" mode="structure">
 		<xsl:variable name="id" select="string(bug_id)" />
 		<xsl:variable name="self" select="." />
@@ -120,8 +126,9 @@
 			</xsl:if>
 
 			<!-- filter out dependencies -->
+			<!-- exclude children, and missing bugs -->
 			<xsl:variable name="dependencies"
-				select="dependson[not(text() = exsl:node-set($parents)/bug[@parent = $id]/@id)]" />
+				select="dependson[not(text() = exsl:node-set($parents)/bug/parent[@id=$id]/@bugid)][key('bugid', .)]" />
 			<xsl:for-each select="$dependencies">
 				<dependency id="{.}" />
 			</xsl:for-each>
@@ -132,7 +139,7 @@
 	<xsl:template match="/">
 		<xsl:apply-templates select="exsl:node-set($structure)/bug">
 			<xsl:with-param name="indent" select="0" />
-			<xsl:with-param name="chargeset" select="$chargeset"/>
+			<xsl:with-param name="chargeset" select="$chargeset" />
 		</xsl:apply-templates>
 	</xsl:template>
 
@@ -141,6 +148,8 @@
 		<xsl:param name="chargeset" />
 		<xsl:variable name="id" select="@id" />
 		<xsl:variable name="details" select="$bugs[bug_id = $id]" />
+		<xsl:variable name="hasTime"
+			select="number($details/estimated_time) or number($details/actual_time) or number($details/remaining_time)" />
 
 		<!-- task header -->
 		<xsl:call-template name="start-task">
@@ -152,11 +161,12 @@
 			</xsl:with-param>
 			<xsl:with-param name="desc" select="@desc" />
 		</xsl:call-template>
-		
+
 		<xsl:if test="$chargeset">
 			<xsl:call-template name="println">
-				<xsl:with-param name="indent" select="$indent + 1"/>
-				<xsl:with-param name="text" select="concat('chargeset ', $chargeset)"/>
+				<xsl:with-param name="indent" select="$indent + 1" />
+				<xsl:with-param name="text"
+					select="concat('chargeset ', $chargeset)" />
 			</xsl:call-template>
 		</xsl:if>
 
@@ -175,8 +185,7 @@
 					<xsl:with-param name="indent" select="$indent + 1" />
 				</xsl:apply-templates>
 
-				<xsl:if
-					test="number($details/estimated_time) or number($details/actual_time) or number($details/remaining_time)">
+				<xsl:if test="$hasTime">
 					<xsl:call-template name="start-task">
 						<xsl:with-param name="indent" select="$indent + 1" />
 						<xsl:with-param name="id" select="'manage'" />
@@ -186,6 +195,7 @@
 						select="$details/estimated_time | $details/actual_time | $details/remaining_time | $details/assigned_to"
 						mode="task-details">
 						<xsl:with-param name="indent" select="$indent + 2" />
+						<xsl:with-param name="hasTime" select="$hasTime" />
 					</xsl:apply-templates>
 					<xsl:call-template name="end-task">
 						<xsl:with-param name="indent" select="$indent + 1" />
@@ -196,6 +206,7 @@
 				<xsl:apply-templates select="$details/node()"
 					mode="task-details">
 					<xsl:with-param name="indent" select="$indent + 1" />
+					<xsl:with-param name="hasTime" select="$hasTime" />
 				</xsl:apply-templates>
 			</xsl:otherwise>
 		</xsl:choose>
@@ -243,13 +254,17 @@
 
 	<xsl:template match="assigned_to" mode="task-details">
 		<xsl:param name="indent" />
-		<xsl:variable name="email" select="string(.)" />
-		<xsl:variable name="resource" select="$resources[@email = $email]/@id" />
-		<xsl:if test="$resource">
-			<xsl:call-template name="println">
-				<xsl:with-param name="indent" select="$indent" />
-				<xsl:with-param name="text" select="concat('allocate ', $resource)" />
-			</xsl:call-template>
+		<xsl:param name="hasTime" />
+		<xsl:if test="$hasTime">
+			<xsl:variable name="email" select="string(.)" />
+			<xsl:variable name="resource" select="$resources[@email = $email]/@id" />
+			<xsl:if test="$resource">
+				<xsl:call-template name="println">
+					<xsl:with-param name="indent" select="$indent" />
+					<xsl:with-param name="text"
+						select="concat('allocate ', $resource)" />
+				</xsl:call-template>
+			</xsl:if>
 		</xsl:if>
 	</xsl:template>
 	<xsl:template match="text()" mode="task-details">
@@ -376,7 +391,7 @@
 		<xsl:param name="count" select="0" />
 
 		<xsl:if test="number($count)">
-			<xsl:copy-of select="$value" />
+			<xsl:value-of select="$value" />
 			<xsl:call-template name="repeat">
 				<xsl:with-param name="value" select="$value" />
 				<xsl:with-param name="count" select="$count - 1" />