posted 7 years ago
Well... you might have one or two questions there. So let's just answer both of them.
First: "How do I do if-then-else in XSLT?"
Answer: Use the <xsl:choose>, <xsl:when>, and <xsl:otherwise> elements. (I'm not going to go into details because you could read the documentation and find tutorials for those things. Much easier for both of us.)
Second: How do I use XSLT to find out whether a node exists?
You already know how to write an XPath expression which identifies the node. Coercing such an expression to boolean produces true if the node exists and false if not. So you can then write <xsl:if test="XPath expression"> or <xsl:choose test="XPath expression"> and follow that up with some code which will only be executed if the node exists. If your expression identifies more than one node, coercing it to boolean still returns true.