Reputation: 1
In XSLT 2.0, can we use if then only means no else clause.
<Employee><Status><xsl:value-of select="if (tns:Employee/tns:EmpId = 4) then 'new' else 'old'"/></Status></Employee>
Here if I don't want else clause, means if empid is not 4, then do not populate Status field. what will be xslt?
Upvotes: 0
Views: 1950
Reputation: 70628
If you don't want any status
at all, you can easily achieve this with the standard xsl:if
in XSLT (available in all versions)
<Employee>
<xsl:if test="tns:Employee/tns:EmpId = 4">
<Status>new</Status>
</xsl:if>
</Employee>
Upvotes: 1
Reputation: 52878
Unless I'm reading the question wrong, just add an empty string or empty sequence.
Example...
if (tns:Employee/tns:EmpId = 4) then 'new' else ''
or
if (tns:Employee/tns:EmpId = 4) then 'new' else ()
Upvotes: 2