IMPORTANT: updated with solution!
See JAXB 2.x with MOXy (Eclipselink 2.1.2): persisting XHTML as element value
I want to store XHTML as a node value of an XML via JAXB, e.g.
<p>This is a paragraph</p>
should get stored “as is” in an XML:
<root>
<title>Title</title>
<content>...the above XHTML snippet of paragraph...</content>
</root>
As I am using MOXy as JAXB Impl, I wanted to try this (version 2.1.2):
@XmlCDATA
public void setContent(String content) {
this.content = content;
}
However, the content gets marshalled as escaped code and I can’t display it afterwards as XHTML snippet.
First of all: Where can I download the latest release of MOXy? It might be a bug in 2.1.2. The maven repo is somehow not available anymore:
http://download.eclipse.org/rt/eclipselink/maven.repo
The link was found at
http://wiki.eclipse.org/EclipseLink/Maven
Thanks
Update and solution regarding MOXy version 2.3.0:
I have tried out version 2.3.0 of EclipseLink now and it works!
Here is my data object that I persist:
and the MOXy enabling config files:
package-info.java:and the
jaxb.properties:When I write an instance of DialogMessage as XML to disk, the XML looks like this:
Please note that “…” is just a replacement for whatever namespace URI you have.