users@jaxb.java.net

Re: How to marshal element without XML prolog, to avoid content before prolog?

From: Pavel Bucek <Pavel.Bucek_at_Sun.COM>
Date: Sat, 09 Jan 2010 09:50:40 +0100

You should try set Marshaller.JAXB_FRAGMENT property to true.

see
http://java.sun.com/javase/6/docs/api/javax/xml/bind/Marshaller.html#JAXB_FRAGMENT

marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);

Regards,
Pavel

KARR, DAVID (ATTCINW) wrote:
> I've got some code where I have to construct a SOAP message string,
> where I have objects that I can marshal with JAXB, whose marshaled
> content has to go into the SOAP message. I'm presently just trying to
> marshal each of the individual objects, then appending that to my XML
> string. The problem appears to be that the resulting marshaled output
> of each object contains an XML prolog. When I put the resulting
> substring into the total SOAP message string, I end up with "content
> before prolog" errors, which seems reasonable under the circumstances.
>
> Is there an easy way to make the marshalling process not emit the XML
> prolog, as opposed to trying to manually remove the prolog at the start
> of each fragment?
>
> I was avoiding trying to do this with SAAJ, I'm not sure whether that
> will be harder or not.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>