Input is:
<s> <w>u.<reg>und</reg> </w> <w>für</w> <w>die</w> <w>Folge</w> <w>da</w> <w>werden</w> <w>Sie</w>, <persName> <w>Gnädigste<reg>gnädigste</reg></w> <lb/> <w>Tante<c>,</c></w> </persName> <w>schon</w> <w>sorgen</w>. </s>
Output should be: <s>u. für die Folge da werden Sie, Gnädigste Tante, schon sorgen.</s>
The attached query may give you some inspiration. The result will *mostly* be the same as the one you are looking for. However, "<w>Gnädigste<reg>gnädigste</reg></w>" will result in "Gnädigste<reg>gnädigste". If you want to enforce whitespace between each element, you can replace "normalize-space($s)" with:
normalize-space(string-join($s//text(), ' '))
Christian ________________________________
(: I used an input string and fn:parse-xml to preserve the original whitespaces. If your whitespaces are erroneously chopped in your database, you can avoid this by setting the 'chop' option to false. :)
let $input := "<s> <w>u.<reg>und</reg> </w> <w>für</w> <w>die</w> <w>Folge</w> <w>da</w> <w>werden</w> <w>Sie</w>, <persName> <w>Gnädigste<reg>gnädigste</reg></w> <lb/> <w>Tante<c>,</c></w> </persName> <w>schon</w> <w>sorgen</w>. </s>" let $xml := parse-xml($input) return $xml update ( for $s in s return replace value of node $s with normalize-space($s) )