if not exists:
<xsl:if test="not (/rows/row/@user)"> ... </xsl:if>
if exists:
<xsl:if test="/rows/row/@user"> ... </xsl:if>
if…then…else:
<xsl:choose> <xsl:when test="name[.!='']"> <xsl:value-of select="name"/> </xsl:when> <xsl:otherwise> More Info </xsl:otherwise> </xsl:choose>
Compare to a numeric value:
<xsl:choose> <xsl:when test="customerCount[.='0']"> ... </xsl:when> <xsl:otherwise> ... </xsl:otherwise> </xsl:choose>
xsl:if test
// Test for the presence of the attribute @var <xsl:if test="@var">...</xsl:if> <!-- only true if the @var is present --> // Test to see if the value of attribute var is not "" <xsl:if test="string-length(@var) > 0">...</xsl:if> // Trim/compress the spaces in the attribute such that " " <xsl:if test="string-length(normalize-space(@var)) > 0">...</xsl:if>
Check if the field CategoryName has any text:
<xsl:if test="CategoryName/text()">X</xsl:if> <xsl:if test="CategoryName != ''">Y</xsl:if>