Requirements Traceability to Test Cases
In the standard requirements traceability report, we use the following XSLT selector to display a list of test cases associated with the current requirement node:
<xsl:for-each select="TestCases/TestCase">
<xsl:if test="position() > 1">
, TC<xsl:value-of select="TestCaseId"/>
</xsl:if>
<xsl:if test="position() = 1">
TC<xsl:value-of select="TestCaseId"/>
</xsl:if>
</xsl:for-each>
however when you want to include the list of requirements under a parent requirement, and then display its associated test cases, you will need to use the following selector:
<xsl:for-each select="following-sibling::Requirement[substring(IndentLevel,1,string-length (current()/IndentLevel)) = current()/IndentLevel]/TestCases/TestCase">
<xsl:if test="position() > 1">
, TC<xsl:value-of select="TestCaseId"/>
</xsl:if>
<xsl:if test="position() = 1">
TC<xsl:value-of select="TestCaseId"/>
</xsl:if>
</xsl:for-each>
This works because the IndentLevel field is used by requirements to display the hierarchical ordering of the requirements, so we're asking the system to find all nodes that have the same parent indent level as the current node but come after the current node (following-siblings in XSLT parlance).