Most of the time, however, Booleans are created by comparisons
between other objects, most commonly numbers. XPath provides all the
usual relational operators including =,
!=, <,
>, >=, and
<=. In addition, the and and
or operators can combine Boolean expressions
according to the usual rules of logic.
Booleans are most commonly used in predicates of location paths. For
example, in the location step
person[profession="physicist"],
profession="physicist" is a Boolean. It is either
true or false; there is no other possibility. Booleans are also
commonly used in the test attribute of
xsl:if and xsl:when elements.
For example, this XSLT template rule includes the
profession element in the output only if its
contents are "physicist" or
"computer scientist":
<xsl:template match="profession">
<xsl:if test=".='computer scientist' or .='physicist'">
<xsl:value-of select="."/>
</xsl:if>
</xsl:template>
This XSLT template rule italicizes the profession
element if and only if its content is the string
"computer scientist":
<xsl:template match="profession">
<xsl:choose>
<xsl:when test=".='computer scientist'">
<i><xsl:value-of select="."/></i>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>