Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6689495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:31:33+00:00 2026-05-26T05:31:33+00:00

IMPORTANT: updated with solution! See JAXB 2.x with MOXy (Eclipselink 2.1.2): persisting XHTML as

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T05:31:33+00:00Added an answer on May 26, 2026 at 5:31 am

    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:

    import org.eclipse.persistence.oxm.annotations.XmlCDATA;
    
    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlRootElement(name=DialogMessage.ROOTNAME, namespace="...")
    public class DialogMessage {
    
        @XmlTransient
        public static final String ROOTNAME = "dialog";
    
        @XmlElement(name="content-html", namespace="...")
        @XmlCDATA
        private String contentHTML = null;
    
        public String getContentHTML() {
            return contentHTML;
        }
    
        public void setContentHTML(String contentHTML) {
            this.contentHTML = contentHTML;
        }
    
    }
    

    and the MOXy enabling config files:
    package-info.java:

    @javax.xml.bind.annotation.XmlSchema( 
        namespace = "...", 
        xmlns = {@javax.xml.bind.annotation.XmlNs(prefix = "z", namespaceURI ="...")},  
        elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) 
    package com.yourdomain.packagenametodataclass; 
    

    and the jaxb.properties:

    javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory
    

    When I write an instance of DialogMessage as XML to disk, the XML looks like this:

    <?xml version="1.0" encoding="UTF-8"?>
    <z:dialog xmlns:z="...">
       <z:content-html><![CDATA[<p>sgd <strong>asdf</strong> asdf&#160;</p>
    <p>asdf</p>]]></z:content-html>
    </z:dialog>
    

    Please note that “…” is just a replacement for whatever namespace URI you have.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just updated to Snow Leopard and one of my important Flash files
Important : Please see this very much related question: Return multiple values in C++
Note, I have found the solution to my problem. Please see below. I'm converting
I have the following XML <AllVendors xmlns=http://important/data> <Vendor> <VendorId>1</VendorId> <VendorName>Vendor A</VendorName> </Vendor> <Vendor> <VendorId>2</VendorId>
Important Update Since the release of MVC 2.0 Preview 1 this feature has been
Important: This question isn't actually really an ASP.NET question. Anyone who knows anything about
IMPORTANT EDIT: Sorry everyone, i made a big mistake in the structure. char *name;
How important is it to make a website layout fit on 640 x 480
Some important part of my code is running in viewDidLoad and I was wondering
It will be important for developers wanting to develop for the chrome browser to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.