Desired Report

A customer that was using Spira to write their requirements, had created a custom requirements template using the following requirement custom properties:

The first 4 custom properties were rich text, the last two were plain text. You could also make the last two (is it out of the box and difficulty level) list-based custom properties. For simplicity in this example, we have kept them plain text.

The customer was looking to turn these custom properties into a report that looks like the following:

(a) PDF Output

(b) MS-Word Output

The data in the system looks like the following:

and in the list view:

Creating the Custom Report

So, to create the custom report, we cloned the built-in Requirements Detailed Report and then used the following XSLT template to replace the default:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
  <xsl:template match="/RequirementData">
    <xsl:for-each select="Requirement">
	  <table class="DataGrid">
		<tr>
		  <th colspan="2">
			RQ:<xsl:value-of select="RequirementId"/> - <xsl:value-of select="Name"/>
		  </th>
		</tr>
		  <tr>
			<td>
			  Description
			</td>
			<td>
				<xsl:value-of select="Description" disable-output-escaping="yes"/>
			</td>
		  </tr>
		  <tr>
			<td>
			  Actor
			</td>
			<td>
				<xsl:value-of select="CustomProperties/CustomProperty[Name = 'Custom_01']/Value" disable-output-escaping="yes"/>
			</td>
		  </tr>
		  <tr>
			<td>
			  Pre-Conditions
			</td>
			<td>
				<xsl:value-of select="CustomProperties/CustomProperty[Name = 'Custom_02']/Value" disable-output-escaping="yes"/>
			</td>
		  </tr>
		  <tr>
			<td>
			  Steps
			</td>
			<td>
				<xsl:value-of select="CustomProperties/CustomProperty[Name = 'Custom_03']/Value" disable-output-escaping="yes"/>
			</td>
		  </tr>
		  <tr>
			<td>
			  Post - Conditions
			</td>
			<td>
				<xsl:value-of select="CustomProperties/CustomProperty[Name = 'Custom_04']/Value" disable-output-escaping="yes"/>
			</td>
		  </tr>
		  <tr>
			<td>
			  OOTB?
			</td>
			<td>
				<xsl:value-of select="CustomProperties/CustomProperty[Name = 'Custom_05']/Value" disable-output-escaping="no"/>
			</td>
		  </tr>
		  <tr>
			<td>
			  Difficulty Level
			</td>
			<td>
				<xsl:value-of select="CustomProperties/CustomProperty[Name = 'Custom_06']/Value" disable-output-escaping="no"/>
			</td>
		  </tr>
	  </table>
    </xsl:for-each>
  </xsl:template>
  <xsl:template name="format-date">
    <xsl:param name="datetime"/>
    <xsl:variable name="date" select="substring-before($datetime, 'T')" />
    <xsl:variable name="year" select="substring-before($date, '-')" />
    <xsl:variable name="month" select="substring-before(substring-after($date, '-'), '-')" />
    <xsl:variable name="day" select="substring-after(substring-after($date, '-'), '-')" />
    <xsl:variable name="time" select="substring-before(substring-after($datetime, 'T'), '.')" />
    <xsl:variable name="monthname">
      <xsl:choose>
        <xsl:when test="$month='01'">
          <xsl:value-of select="'Jan'"/>
        </xsl:when>
        <xsl:when test="$month='02'">
          <xsl:value-of select="'Feb'"/>
        </xsl:when>
        <xsl:when test="$month='03'">
          <xsl:value-of select="'Mar'"/>
        </xsl:when>
        <xsl:when test="$month='04'">
          <xsl:value-of select="'Apr'"/>
        </xsl:when>
        <xsl:when test="$month='05'">
          <xsl:value-of select="'May'"/>
        </xsl:when>
        <xsl:when test="$month='06'">
          <xsl:value-of select="'Jun'"/>
        </xsl:when>
        <xsl:when test="$month='07'">
          <xsl:value-of select="'Jul'"/>
        </xsl:when>
        <xsl:when test="$month='08'">
          <xsl:value-of select="'Aug'"/>
        </xsl:when>
        <xsl:when test="$month='09'">
          <xsl:value-of select="'Sep'"/>
        </xsl:when>
        <xsl:when test="$month='10'">
          <xsl:value-of select="'Oct'"/>
        </xsl:when>
        <xsl:when test="$month='11'">
          <xsl:value-of select="'Nov'"/>
        </xsl:when>
        <xsl:when test="$month='12'">
          <xsl:value-of select="'Dec'"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="''" />
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:value-of select="concat($day, '-' ,$monthname, '-', $year , ' ', $time)" />
  </xsl:template>
</xsl:stylesheet>

Once we saved the report, we can now run this new report and generate the desired output.

We have attached copies of the full PDF and MS-Word reports to this KB Article for reference.