The floor() function

Smartsite 7.4 - ...

The floor() XPath 2.0 function rounds arg downwards to a whole number.

XML CopyCode image Copy Code
numeric fn:floor(arg)

Parameters:

  • arg: a node reference or literal.

Example

XML CopyCode image Copy Code
<html xmlns="http://www.w3.org/1999/xhtml" 
 xmlns:xf="http://www.w3.org/2002/xforms" 
 xmlns:fn="http://www.w3.org/2005/xpath-functions"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <head>
  <title>Example</title>
  <xf:model>
   <xf:instance>
    <data xmlns="">
     <pos>10.5</pos>
     <neg>-10.5</neg>
    </data>
   </xf:instance>
  </xf:model>
 </head>
 <body>
  <xf:group>
   <xf:output value="fn:floor(pos)" />
   <xf:output value="fn:floor(neg)" />
   <xf:output value="fn:floor(10.6)" />
   <xf:output value="fn:floor(10.4)" />
  </xf:group>
 </body>
</html>

The result will be:

10
-11
10
10

Namespace

This function is available within the XPath 2.0 namespace (http://www.w3.org/2005/xpath-functions).