.. _max: === max === The maximum of a sequence of values Description ~~~~~~~~~~~ The fn:max function finds the maximum of a sequence of values. The $arg sequence can only contain values of one type, or a type derived from it. The one exception is that they can be all numeric (of different numeric types), in which case numeric promotion rules apply. That type must be ordered; it must be possible to compare the values using the < and > operators. The fn:max function assumes untyped values are numeric unless they are explicitly cast to xs:string. To treat untyped data as strings, use the fn:string function as shown in the last example below. .. list-table:: :widths: 40 60 :header-rows: 1 * - **Parameters** - **Description** * - arg:integer() - the sequence of values * - collation:string() - the collation to use for comparing strings Examples ~~~~~~~~ .. list-table:: :widths: 50 50 :header-rows: 1 * - **XPath** - **Results** * - max( (2, 1, 5, 4, 3) ) - 5 * - max( ('a', 'b', 'c') ) - c * - max((xs:date('1999-04-15'), current-date()) ) - The current date * - max( ('a', 'b', 1) ) - Error FORG0006 * - max ( 2 ) - 2 * - max($ordDoc//item/@dept) - Error, if dept is untyped * - max($ordDoc//item/string(@dept)) - WMN See Also ~~~~~~~~ .. toctree:: :titlesonly: :glob: * :ref:`functx_max-determine-type`. * :ref:`functx_max-node`. * :ref:`functx_max-string`. * :ref:`min`.