August 2001
Intermediate to advanced
480 pages
11h 16m
English
true() Function — Always returns the boolean value true.
booleantrue()
None.
The boolean value true.
XPath section 4.3, Boolean Functions.
Here’s a brief example that uses the true() function:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:variable name="newline">
<xsl:text>
</xsl:text>
</xsl:variable>
<xsl:template match="/">
<xsl:value-of select="$newline"/>
<xsl:text>A test of the true() function:</xsl:text>
<xsl:value-of select="$newline"/>
<xsl:value-of select="$newline"/>
<xsl:choose>
<xsl:when test="true()">
<xsl:text> "true()" returned true!</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text> "true()" returned false!</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>When using this stylesheet against any XML document, it generates this less-than-exciting result:
A test of the true() function: "true()" returned true!