home contribute faq download

FunctX XQuery Functions

functx:max-line-length

The maximum line length

Google
Webxqueryfunctions.com

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.

Arguments and Return Type

NameTypeDescription
$arg xs:string? the string to test
return value xs:integer

XQuery Function Declaration

See XSLT definition.
XQuery Syntax for July 2004 - January 2007 (1.0):
declare namespace functx = "http://www.functx.com"; 
declare function functx:max-line-length 
  ( $arg as xs:string? )  as xs:integer {
       
   max(
     for $line in functx:lines($arg)
     return string-length($line))
 } ;
XQuery Syntax for May 2003:
declare namespace functx = "http://www.functx.com" 
define function max-line-length 
  ( $arg as xs:string? )  as xs:integer {
       
   fn:max(
     for $line in functx:lines($arg)
     return fn:string-length($line))
 }

Examples

let $lines :=
'a
value
on several
lines'
return
XQuery ExampleResults
functx:max-line-length('a value')
7
functx:max-line-length($lines)
10

Depends On

functx:linesSplit a string into separate lines

See Also

functx:line-countThe number of lines

History

Published OnLast UpdatedContributor(s)
2006-07-092007-02-26Priscilla Walmsley, Datypic, pwalmsley@datypic.com, http://www.datypic.com
Need XQuery Help?
D A T Y P I C
Training | Consulting | Development

XQuery by Priscilla WalmsleyGet the book!
XQuery by Priscilla Walmsley