XML technologies / XSLT / XSLT and XPath functions / Alphabetical XSLT and XPath reference / true

(Excerpt from “XSLT 2.0 & XPath 2.0” by Frank Bongers, chapter 5, translated from German)

A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

fn:true

Category:

Boolean functions

Origin:

XPath 1.0

Return value:

The Boolean value true.

Call/Arguments:

fn:true()

No arguments.

Purpose of use:

Since in XPath no Boolean constants (or literals) true or false exist, the functions fn:true() or fn:false() are used when such a value is required.

Example 1 – application in the test and debugging phase:

The fn:true() function can be used in order to, for example, enforce the processing of parts of stylesheets during the development, as long as it is not yet possible to impose final conditions:

<xsl:when test="fn:true()"> ... do something ... </xsl:when>

In this case, the conditional instruction block is always executed.

Example 2 – passing on Boolean 'true' to a named template:

When calling up a named template, a parameter can be set to true in the following way:

<xsl:call-template name="with_name">
  <xsl:with-param name="the_parameter" select="fn:true()"/>
</xsl:call-template>

Function definition:

XPath 1.0:

true() => boolean

XPath 2.0:

fn:true() as xs:boolean

   

 

 

 

back to top