Reputation: 27
Is it possible to have the table display ONLY parent nodes that do not have child nodes? I only want items AT-2 and AT-3 to display in the table...
XML:
<root>
<Item type="Acceptance Test">
<jav_acc_id>AT-1</jav_acc_id>
<Relationships>
<Item type="Acceptance Test Requirements">
<related_id>
<Item type="Requirement">
<item_number>REQ-1</item_number>
</Item>
</related_id>
</Item>
</Relationships>
</Item>
<Item type="Acceptance Test">
<jav_acc_id>AT-2</jav_acc_id>
</Item>
<Item type="Acceptance Test">
<jav_acc_id>AT-3</jav_acc_id>
</Item>
</root>
This is what I have so far that displays it all XSLT1.0:
<xsl:template match="/root">
<html>
<body>
<table border="1">
<tr bgcolor="#9acd32">
<th>Acceptance Test</th>
<th>Requirement</th>
</tr>
<tr>
<xsl:for-each select="Item">
<tr>
<td>
<xsl:value-of select="jav_acc_id"/>
</td>
<td>
<xsl:value-of select=".//item_number"/>
<xsl:if test=".//item_number='' or not(.//item_number)">
<xsl:text> </xsl:text>
</xsl:if>
</td>
</tr>
</xsl:for-each>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Upvotes: 0
Views: 354
Reputation: 9093
You can test for the absence of <Relationships>
with <xsl:if>
like this:
<xsl:for-each select="Item">
<tr>
<xsl:if test="not(Relationships)">
...
</xsl:if>
</tr>
</xsl:for-each>
Upvotes: 1