Reputation: 273
I have an XML file which is getting embedded into the master xml file, below is the xml file format
<TEST_RESULT>
<MODULE_NAME>CREATE-SETVC-NUM</MODULE_NAME>
<CLASS_NAME>Create</CLASS_NAME>
<NUMBER_OF_PASSED>4</NUMBER_OF_PASSED>
<NUMBER_OF_FAILED>4</NUMBER_OF_FAILED>
<TOTAL_COUNT>8</TOTAL_COUNT>
<CLASS_NAME1>SetVC</CLASS_NAME1>
<NUMBER_OF_PASSED1>4</NUMBER_OF_PASSED1>
<NUMBER_OF_FAILED1>4</NUMBER_OF_FAILED1>
<TOTAL_COUNT1>8</TOTAL_COUNT1>
</TEST_RESULT>
Now my XSLT file i need to check an condition that when nodes <CLASS_NAME>
and <CLASS_NAME1>
both nodes exists need to perform some operation, now i tried this below condition
<xsl:when test="CLASS_NAME and CLASS_NAME1">
<tr>
<td rowspan="2" bgcolor = "#E0FFFF"><font face = "courier"><b><xsl:value-of select="MODULE_NAME"/></b></font></td>
<td bgcolor = "#E0FFFF"><font face = "courier"><b><xsl:value-of select="CLASS_NAME"/></b></font></td>
<td bgcolor = "#E0FFFF"><font face = "courier"><b><xsl:value-of select="NUMBER_OF_PASSED"/></b></font></td>
<td bgcolor = "#E0FFFF"><font face = "courier"><b><xsl:value-of select="NUMBER_OF_FAILED"/></b></font></td>
<td bgcolor = "#E0FFFF"><font face = "courier"><b><xsl:value-of select="TOTAL_COUNT"/></b></font></td>
</tr>
<tr>
<td bgcolor = "#E0FFFF"><font face = "courier"><b><xsl:value-of select="CLASS_NAME1"/></b></font></td>
<td bgcolor = "#E0FFFF"><font face = "courier"><b><xsl:value-of select="NUMBER_OF_PASSED1"/></b></font></td>
<td bgcolor = "#E0FFFF"><font face = "courier"><b><xsl:value-of select="NUMBER_OF_FAILED1"/></b></font></td>
<td bgcolor = "#E0FFFF"><font face = "courier"><b><xsl:value-of select="TOTAL_COUNT1"/></b></font></td>
</tr>
</xsl:when>
but this condition is failing any idea why its failing?
Upvotes: 2
Views: 2721
Reputation: 1289
xsl If condition to match a template,
<xsl:if test="expr">
<!-- your code -->
</xsl:if>
element is used in conjunction with and to express multiple conditional tests.
`<xsl:choose>
<xsl:when test="expr">
<!-- your code -->
</xsl:when>
<xsl:otherwise>
<!-- your code -->
</xsl:otherwise>
`
,
Reference:
[w3schools.com/xsl/] [zvon.org/comp/r/ref-XSLT_1.html]
to learn xslt zvon is very good site for newbies :)
Upvotes: 1
Reputation: 8080
needs to be either:
<xsl:choose>
<xsl:when test="CLASS_NAME and CLASS_NAME1">
</xsl:when>
</xsl:choose>
or:
<xsl:if test="CLASS_NAME and CLASS_NAME1">
</xsl:if>
Upvotes: 3