Hi Andreas -
Have you tried using different serialization options? I.e.,
serialize.xq:
```
declare option output:method "xml";
declare option output:parameter-document "map.xml";
declare variable $input := "<p>Lorem ipsum, ' dolor sit amet.</p>";
serialize($input)
```
map.xml:
```
```
When run in the BaseX GUI, I get:
`&lt;p&gt;Lorem ipsum, ' dolor sit amet.&lt;/p&gt;`, might be closer?
I think you might have been experiencing the default 'basex' serialization option (see [1] for more).
Hope that helps.
Best,
Bridger