Project

Profile

Help

Bug #2070 ยป resolveHistoryLists.xsl

Philipp Nanz, 2014-05-07 23:26

 
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: resolveHistoryLists.xsl,v 1.15 2009/12/15 08:01:52 heiko Exp $ -->
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="history-expand">
</xsl:template>
<xsl:template match="history-list">
<xsl:if test="not(preceding-sibling::history-list | preceding-sibling::history)">
<history-expand>
<xsl:apply-templates select=". |following-sibling::history-list | following-sibling::history" mode="history-expand"/>
</history-expand>
</xsl:if>
</xsl:template>
<xsl:template match="history">
<xsl:if test="not(preceding-sibling::history-list | preceding-sibling::history)">
<history-expand>
<xsl:apply-templates select=". |following-sibling::history-list | following-sibling::history" mode="history-expand"/>
</history-expand>
</xsl:if>
</xsl:template>

<xsl:template match="history-list" mode="history-expand">
<!--xsl:variable name="histories">
<histories>
<xsl:choose>
<xsl:when test="@expand='all'">
<xsl:copy-of select="//history/history-entry"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="ancestor::chapter[1]/descendant::history/history-entry"/>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="@sortby='date'">
<xsl:copy-of select="milestone/history-entry"/>
</xsl:if>
</histories>
</xsl:variable-->
<!--xsl:variable name="expand" select="@expand"></xsl:variable>
<xsl:variable name="histories" select="$expand='all' and //history/history-entry
| milestone[parent::*[@sortby='date']]/history-entry
| $expand='chapter' and ancestor::chapter[1]/descendant::history/history-entry">
</xsl:variable-->
<xsl:variable name="sortby" select="@sortby"></xsl:variable>
<xsl:variable name="order" select="@sortorder"></xsl:variable>
<!--xsl:variable name="order">
<xsl:choose>
<xsl:when test="@sortorder = 'ascending'">ascending</xsl:when>
<xsl:otherwise>descending</xsl:otherwise>
</xsl:choose>
</xsl:variable-->
<xsl:if test="@expand='all' and //history/history-entry
or milestone[parent::*[@sortby='date']]/history-entry
or @expand='chapter' and ancestor::chapter[1]/descendant::history/history-entry">
<table width="100%" border="0" cellpadding="0" cellspacing="0" align="leftpage">
<xsl:if test="/spec">
<xsl:attribute name="fontsize">small</xsl:attribute>
</xsl:if>
<xsl:attribute name="y.id">
<xsl:text>history-list_</xsl:text>
<xsl:value-of select="generate-id()"/>
</xsl:attribute>
<tbody>
<xsl:choose>
<xsl:when test="@expand='all'">
<xsl:choose>
<xsl:when test="$sortby='date'">
<xsl:for-each-group select="//history/history-entry | milestone[parent::*[@sortby='date']]/history-entry" group-by="@y.id">
<xsl:sort select="substring(date,1,4)" order="{$order}"/> <!-- year -->
<xsl:sort select="substring(date,6,2)" order="{$order}"/> <!-- month -->
<xsl:sort select="substring(date,9,2)" order="{$order}"/> <!-- day -->
<xsl:sort select="position()" data-type="number" order="{$order}"/> <!-- COSMICEXT-866 -->
<xsl:call-template name="add.history.entry"/>
</xsl:for-each-group>
</xsl:when>
<xsl:when test="$sortby='jira'">
<xsl:for-each-group select="//history/history-entry | milestone[parent::*[@sortby='date']]/history-entry" group-by="@y.id">
<xsl:sort select="jira" order="{$order}"></xsl:sort>
<xsl:call-template name="add.history.entry"/>
</xsl:for-each-group>
</xsl:when>
<xsl:when test="$sortby='chapter'">
<xsl:for-each-group select="//history/history-entry | milestone[parent::*[@sortby='date']]/history-entry" group-by="@y.id">
<xsl:sort order="{$order}" select="count(preceding::chapter | ancestor::chapter)"/>
<xsl:call-template name="add.history.entry"/>
</xsl:for-each-group>
</xsl:when>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="$sortby='date'">
<xsl:for-each-group select="ancestor::chapter[1]/descendant::history/history-entry | milestone[parent::*[@sortby='date']]/history-entry" group-by="@y.id">
<xsl:sort select="substring(date,1,4)" order="{$order}"/> <!-- year -->
<xsl:sort select="substring(date,6,2)" order="{$order}"/> <!-- month -->
<xsl:sort select="substring(date,9,2)" order="{$order}"/> <!-- day -->
<xsl:sort select="position()" data-type="number" order="{$order}"/> <!-- COSMICEXT-866 -->
<xsl:call-template name="add.history.entry"/>
</xsl:for-each-group>
</xsl:when>
<xsl:when test="$sortby='jira'">
<xsl:for-each-group select="ancestor::chapter[1]/descendant::history/history-entry | milestone[parent::*[@sortby='date']]/history-entry" group-by="@y.id">
<xsl:sort select="jira" order="{$order}"></xsl:sort>
<xsl:call-template name="add.history.entry"/>
</xsl:for-each-group>
</xsl:when>
<xsl:when test="$sortby='chapter'">
<xsl:for-each-group select="ancestor::chapter[1]/descendant::history/history-entry | milestone[parent::*[@sortby='date']]/history-entry" group-by="@y.id">
<xsl:sort order="{$order}" select="count(preceding::chapter | ancestor::chapter)"/>
<xsl:call-template name="add.history.entry"/>
</xsl:for-each-group>
</xsl:when>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</tbody>
</table>
</xsl:if>
</xsl:template>
<xsl:template name="add.history.entry">
<xsl:if test="parent::milestone and parent::milestone/milestone-title/node()">
<tr>
<td />
<td />
<td />
<td />
<td />
<td>
<p>
<xsl:apply-templates select="parent::milestone/milestone-title/node()" />
</p>
</td>
</tr>
</xsl:if>
<tr>
<td>
<xsl:if test="date">
<p>
<xsl:value-of select="date"/>
</p>
</xsl:if>
</td>
<td>
<xsl:if test="date">
<p>
<xsl:value-of select="authorname"/>
</p>
</xsl:if>
</td>
<td>
<p>
<xsl:element name="link">
<xsl:attribute name="y.target.id">
<xsl:value-of select="ancestor::chapter[1]/@y.id"/>
</xsl:attribute>
<xsl:attribute name="y.linktype">
<xsl:value-of select="'any'"/>
</xsl:attribute>
<!-- xsl:number copied from PDF LinkModule.xsl -->
<xsl:element name="e.text">
<xsl:number format="1"
count="chapter|troubleshooting|malfunction-group|module |module-installation | module-maintenance | module-technical-data | module-description | module-troubleshooting"
level="multiple"/>
</xsl:element>
<xsl:element name="p.text">
<xsl:number format="1"
count="chapter|troubleshooting|malfunction-group|module |module-installation | module-maintenance | module-technical-data | module-description | module-troubleshooting"
level="multiple"/>
</xsl:element>
</xsl:element>
</p>
</td>
<td>
</td>
<td>
<xsl:if test="date">
<p>
<xsl:value-of select="status"/>
</p>
</xsl:if>
</td>
<td>
<xsl:apply-templates select="history-desc/node()"/>
</td>
</tr>
</xsl:template>
<xsl:template match="history" mode="history-expand">
<table width="100%" border="0" cellpadding="0" cellspacing="0" align="leftpage">
<xsl:if test="/spec">
<xsl:attribute name="fontsize">small</xsl:attribute>
</xsl:if>
<xsl:attribute name="y.id">
<xsl:text>history_</xsl:text>
<xsl:value-of select="generate-id()"/>
</xsl:attribute>
<tbody>
<xsl:for-each select="history-entry">
<xsl:sort select="substring(date,1,4)" order="descending"/> <!-- year -->
<xsl:sort select="substring(date,6,2)" order="descending"/> <!-- month -->
<xsl:sort select="substring(date,9,2)" order="descending"/> <!-- day -->
<xsl:sort select="position()" data-type="number" order="descending"/> <!-- COSMICEXT-866 -->
<tr>
<td>
<xsl:if test="date">
<p>
<xsl:value-of select="date"/>
</p>
</xsl:if>
</td>
<td>
<xsl:if test="date">
<p>
<xsl:value-of select="authorname"/>
</p>
</xsl:if>
</td>
<td>
<xsl:if test="date">
<p>
<xsl:for-each select="jira | rtc">
<xsl:if test="preceding-sibling::jira | preceding-sibling::rtc">
<xsl:value-of select="', '"/>
</xsl:if>
</xsl:for-each>
</p>
</xsl:if>
</td>
<td>
<xsl:if test="date">
<p>
<xsl:value-of select="status"/>
</p>
</xsl:if>
</td>
<td>
<xsl:apply-templates select="history-desc/node()"/>
</td>
</tr>
</xsl:for-each>
</tbody>
</table>
</xsl:template>
</xsl:stylesheet>
    (1-1/1)