I am trying to substitute the content of an element with its content in a document
What do you mean by that? Wouldn’t the result be the same if you substitute the content with the content?
In the given query, you are replacing the elements with their text nodes; is this what you actually want?
copy $e := doc("document") modify ( for $x in $e//C return replace node $x with $x/text() ) return $e
Although this seems to be a plain query, it never ends when launched, so that I am forced to quit BaseX. Any suggestions? Thanks!
PS: my document contains a lot of the elements I want to change. I do not know whether there si an "easy" alternative to "copy"/"replace"