Name
floor() Function — Returns the largest integer that is not greater than the argument.
Synopsis
numberfloor(
number
)
Inputs
A number. If the argument is not a number, it is transformed into a number as if it had been processed by the number()
function. If the argument cannot be transformed into a number, the floor()
function returns NaN
(not a number).
Output
The largest integer that is not greater than the argument, or NaN
if the argument cannot be converted into a number.
Defined in
XPath section 4.4, Number Functions.
Example
The following stylesheet shows the results of invoking the floor()
function against a variety of values. We’ll use this XML document as input:
<?xml version="1.0"?> <report> <title>Miles Flown in 2001</title> <month sequence="01"> <miles-flown>12379</miles-flown> <miles-earned>35215</miles-earned> </month> <month sequence="02"> <miles-flown>32857</miles-flown> <miles-earned>92731</miles-earned> </month> <month sequence="03"> <miles-flown>19920</miles-flown> <miles-earned>76725</miles-earned> </month> <month sequence="04"> <miles-flown>18903</miles-flown> <miles-earned>31781</miles-earned> </month> </report>
Here’s the stylesheet that uses the floor()
function:
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:months="Lookup table for month names"> <months:name sequence="01">January</months:name> <months:name sequence="02">February</months:name> <months:name sequence="03">March</months:name> <months:name ...
Get XSLT now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.