users@jaxb.java.net

Re: marshalling problem

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Wed, 15 Nov 2006 17:38:52 -0800

Frank wrote:
> I tried something that Dmitri eluted too to set the item element. I
> did the following:
>
> csds.message.ObjectFactory objFact = new
> csds.message.ObjectFactory();
> csds.message.GetDocResponse gdr = objFact.createGetDocResponse();
> csds.message.GetDocResponse.Item item = new
> csds.message.GetDocResponse.Item();
> gdr.setTime(MeshUtil.setCurrentTime());
> JAXBElement ele = new JAXBElement(new QName("",""),
> String.class, ddsMsg);
> item.setAny(ele);
> gdr.setItem(item);
>
> The weird thing now is if you marshal this xml document out and print it
> out all the "<" & ">" signs for the string ele have been replaced with
> &lt; and &gt;. Any thoughts? Some encoding issue?

That's as expected. '<' and '>' in XML needs to be escaped.

If your string already contains XML, you don't need JAXB to marshal it,
right?

-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com