.. _functx_max-line-length:
======================
functx:max-line-length
======================
The maximum line length
Description
~~~~~~~~~~~
The functx:max-line-length function counts the number of characters in each
line, and returns the maximum. It uses carriage return and/or newline characters
to determine the end of a line. It is useful for determining the amount of space
a fixed-format string will take up on, for example, a web page.
.. list-table::
:widths: 40 60
:header-rows: 1
* - **Parameters**
- **Description**
* - arg:string()
- the string to test
Examples
~~~~~~~~
The examples below use this input document:
.. code-block:: xml
a
value
on several
lines
.. list-table::
:widths: 50 50
:header-rows: 1
* - **XPath**
- **Results**
* - functx:max-line-length('a value')
- 7
* - functx:max-line-length($lines)
- 10
In a generator
~~~~~~~~~~~~~~
Copy the snippet below and paste it in Freemapper, under a language node inside the ``generators`` element. Each line of the pattern prints the result of one example; to see them, run ``mi generate example-functx-max-line-length``.
.. code-block:: text
:class: mi-trecho
[e] example-functx-max-line-length
[e] vars
[e] lines
[e] select
[v] 'a' || codepoints-to-string(10) || 'value' || codepoints-to-string(10) || 'on several' || codepoints-to-string(10) || 'lines'
[e] start
[e] match
[v] /
[e] body
[e] write-pattern
[v] examples
[e] patterns
[e] examples
[v] E01: {{ functx:max-line-length('a value') }}
[v] E02: {{ functx:max-line-length($lines) }}
Depends On
~~~~~~~~~~
* :ref:`functx_lines`.
See Also
~~~~~~~~
.. toctree::
:titlesonly:
:glob:
* :ref:`functx_line-count`.