treblereel / mapper-xml

j2cl/gwt compatible XML marshallers
Apache License 2.0
3 stars 3 forks source link

XmlValue doesn't support XmlCData annotation #99

Closed hasys closed 1 year ago

hasys commented 2 years ago

If you have a XmlValue annotation on the field, it's content correctly converted as XML Element value, but if you add XmlCData, it will be ignored.

Example:

public class User {
         @XmlValue
         @XmlCData
         public String name;
     }

Will produce:

<?xml version='1.0' encoding='UTF-8'?><User>testName</User>

But expected:

<?xml version='1.0' encoding='UTF-8'?><User><![CDATA[testName]]></User>
hasys commented 2 years ago

Hi @treblereel, can't edit assignee here, so just pinging you in comments. Thank you!

treblereel commented 2 years ago

@hasys good catch, thanks, i ll fix it asap

treblereel commented 2 years ago

@hasys for now your case can be fixed by setting @XmlCData(value = false) like here: https://github.com/treblereel/mapper-xml/blob/8be3d4a79cec81d89845bbfaa9f38a2ffc9d8145/tests/jre/src/test/java/org/treblereel/gwt/xml/mapper/client/tests/annotations/cdata/Value.java#L29

hasys commented 2 years ago

@hasys for now your case can be fixed by setting @XmlCData(value = false) like here: https://github.com/treblereel/mapper-xml/blob/8be3d4a79cec81d89845bbfaa9f38a2ffc9d8145/tests/jre/src/test/java/org/treblereel/gwt/xml/mapper/client/tests/annotations/cdata/Value.java#L29

Originally posted by @treblereel in https://github.com/treblereel/mapper-xml/issues/99#issuecomment-988270204

CDATA didn't appear :(

treblereel commented 2 years ago

@hasys ok, i hope https://github.com/treblereel/mapper-xml/commit/0d2c8981a84f6c288901a6771a8777da70a2e921 fixed your issue