(:~ handle textDocument : @author andy bunce :) module namespace text = 'text'; declare record text:rec( lines as xs:string+, separator? as xs:string:=file:line-separator(), text? as fn() as xs:string:= %method fn () { string-join(?lines,?separator) }, line? := %method fn($line) {?lines[$line]} ); declare function text:build($text as xs:string){ let $lines:=tokenize($text, '(\r\n?|\n\r?)') return text:rec($lines) };