home contribute faq download

FunctX XSLT Functions

functx:lines

Split a string into separate lines

Google
Webxsltfunctions.com

Description

The functx:lines function splits a string into individual lines, using the carriage return and newline characters to indicate the end of a line.

Arguments and Return Type

NameTypeDescription
$arg xs:string? the string to split
return value xs:string*

XSLT Function Declaration

See XQuery definition.
XSLT 2.0 Syntax:
<xsl:function name="functx:lines" as="xs:string*" 
              xmlns:functx="http://www.functx.com" >
  <xsl:param name="arg" as="xs:string?"/> 
 
  <xsl:sequence select=" 
   tokenize($arg, '(\r\n?|\n\r?)')
 "/>
   
</xsl:function>

Examples

<xsl:variable name="in-xml" as="item()*">
<in-xml>a
value
on
many
lines</in-xml>
</xsl:variable>
XSLT ExampleResults
functx:lines('a value')
a value
functx:lines($in-xml)
('a',
'value',
'on',
'many',
'lines')

See Also

functx:line-countThe number of lines
functx:max-line-lengthThe maximum line length

History

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

XQuery by Priscilla WalmsleyGet the book!
XQuery by Priscilla Walmsley