Hi Christian,

I have the comment node <!—&#45;—>. If I extract its content with data() in an element, I get the following: <g>&amp;#45;</g>, and it seems there is no way to force &amp;#45; to become &#45; within the element: I found a workaround to replace &amp;#45; with a dash '-', and this seems the best solution at the moment. My problem is that I have to refer to the positions of these characters (as character offsets), and therefore any change when I move a character from a comment node to an element node could break my reference system (indeed, &amp;#45; is not equivalent to &#45; in BaseX: is the rendering of &#45; as &amp;#45; correct?).

Ciao,
Giuseppe



On 26. Apr 2023, at 18:06, Christian Grün <christian.gruen@gmail.com> wrote:

Hi Giuseppe,

However, I am having a hard time to deal with  “&#45;” ( using data(<!--&#45;—>) ), which is rendered as “&amp;45;” , and “>”, which is translated into “&gt;”: I tried a lot, but nothing seems to work: is there a way to keep “&#45;”  and “>” unchanged while serializing to JSON?

Could you provide us with a little self-contained example?

Another issue I am experiencing is that, after JSON serialization, the order of the key-values in a map does not follow that specified in my code

That's correct. If you want the order to be preserved, you’ll need to choose an XML representation for your JSON data.

Ciao,
Christian