jsonix icon indicating copy to clipboard operation
jsonix copied to clipboard

[question] How to add xml declaration to marshalDocument

Open stefanschenk opened this issue 7 years ago • 1 comments
trafficstars

Hi,

I just started with jsonix in my project. I succesfully created a mapping from an xsd and I am able to create a marshalDocument. But whether I use marshalString or marshalDocument, there is no xml declaration (eg. <?xml version="1.0" encoding="UTF-8"?>) present in the generated xml.

I've searched github and stackoverflow, but I'm unable to find an answer on how to add a xml declaration using jsonix.

stefanschenk avatar Feb 08 '18 13:02 stefanschenk

To be honest, I do not know how to do this. Jsonix uses XMLSerializer.serializeToString or node.xml to serialize DOM to string (see Jsonix.DOM.serialize). So I guess XML declaration is not supported yet.

As a workaround you could try to serialize DOM on your own or simply prepend XML declaration to the serialized string.

highsource avatar Feb 08 '18 16:02 highsource