It seems, that I’m on the way. Only one last fix: I’m getting all resulting s twice, one with <mark>, one without. Thanks in advance!
<item> <s xmlns="http://www.tei-c.org/ns/1.0" xmlns:xi="http://www.w3.org/2001/XInclude" xml:id="N111A6">JeztJetzt darf ich zu dem Mittel meine Zuflucht noch nicht ergreifen nehmen, u.und für die Folge da werden Sie, Gnädigstegnädigste <mark>Tante</mark>, schon sorgen.</s> <s xmlns="http://www.tei-c.org/ns/1.0" xmlns:xi="http://www.w3.org/2001/XInclude" xml:id="N111A6">JeztJetzt darf ich zu dem Mittel meine Zuflucht noch nicht ergreifen nehmen, u.und für die Folge da werden Sie, Gnädigstegnädigste Tante, schon sorgen.</s> </item>
The query is db:create('kleist_index_search‘, for $item in db:open('kleist-data‘) return $item update (delete node .//(tei:note|tei:rdg|tei:lb|tei:del|tei:reg|tei:sic), for $s in .//tei:s return replace value of node $s with normalize-space($s)), db:open('kleist-data')/db:path(.))
Günter
Am 07.01.2016 um 10:52 schrieb Christian Grün christian.gruen@gmail.com:
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) )