import module namespace ast="lsp/ast" at "../webapp/lsp/ast/ast.xqm"; (: declare variable $file:="sample.docs/pdfbox.xqm"; :) declare variable $file:="sample.docs/simple.xq"; declare variable $A:="sample.docs/pdfbox.xqm"; unparsed-text($A) =>ast:build({"flatten":true(),"position":true()}) (: update{ for $e in descendant-or-self::element() let $len:=string-length($e) let $before:=$e/preceding-sibling::node()/string-length()=>sum() return (insert node attribute len { $len } into $e, insert node attribute before { $before } into $e ) } :)