Annotation Type XmlCDATA
-
@Target({FIELD,METHOD}) @Retention(RUNTIME) public @interface XmlCDATAWrap the value inside a CDATA section. Normally JAXB will escape certain characters in a string during a marshal operation:
& (as &)< (as <)" (as ")
"1 < 2"without@XmlCDATAwill be marshalled as<foo>1 < 2</foo>. When@XmlCDATAis used the content is marshalled as<foo><![CDATA[1 < 2]]></foo>.Example
import javax.xml.bind.annotation.XmlRootElement; import org.eclipse.persistence.oxm.annotations.XmlCDATA; @XmlRootElement() public class Root { private String foo; @XmlCDATA public String getFoo() { return foo; } public void setFoo(String foo) { this.foo = foo; } }