fn:unparsed-text-lines

The fn:unparsed-text-lines function reads an external resource (for example, a file) and returns its contents as a sequence of strings, one for each line of text in the string representation of the resource.

Signatures

fn:unparsed-text-lines($href as xs:string?) as xs:string*
fn:unparsed-text-lines(
    $href as xs:string?, 
    $encoding as xs:string
) as xs:string*

Properties

This function is deterministic, context-dependent, and focus-independent. It depends on static base URI.

Rules

The unparsed-text-lines function reads an external resource (for example, a file) and returns its string representation as a sequence of strings, separated at newline boundaries.

The result of the single-argument function is the same as the result of the expression fn:tokenize(fn:unparsed-text($href), '\r\n|\r|\n')[not(position()=last() and .='')]. The result of the two-argument function is the same as the result of the expression fn:tokenize(fn:unparsed-text($href, $encoding), '\r\n|\r|\n')[not(position()=last() and .='')].

The result is thus a sequence of strings containing the text of the resource retrieved using the URI, each string representing one line of text. Lines are separated by one of the sequences x0A, x0D, or x0Dx0A. The characters representing the newline are not included in the returned strings. If there are two adjacent newline sequences, a zero-length string will be returned to represent the empty line; but if the external resource ends with the sequence x0A, x0D, or x0Dx0A, the result will be as if this final line ending were not present.

Error Conditions

Error conditions are the same as for the fn:unparsed-text function.

Notes

See the notes for fn:unparsed-text.