users@jaxb.java.net

Re: how to marshal an object to document fragment

From: Gary Gregory <ggregory_at_seagullsw.com>
Date: Mon, 27 Jan 2003 18:43:09 -0500

Actually, how would one simply strip the <?xml ...?> PI?

>>From the SAX Javadoc on ContentHandler: A SAX parser must never report an
XML declaration (XML 1.0, section 2.8) or a text declaration (XML 1.0,
section 4.3.1) using this method.

I have sevaral model objects that I need to serialize into /one/ XML
document. I am happy to create the enclosing document with the top <?xml...>
and a root element, but each time I marshal an object, I do must not have
the <?xml...>

Arg,
Gary

-----Original Message-----
From: Ryan Shoemaker - JavaSoft East [mailto:Ryan.Shoemaker_at_Sun.COM]
Sent: Monday, January 27, 2003 2:29 PM
To: JAXB-INTEREST_at_JAVA.SUN.COM
Subject: Re: how to marshal an object to document fragment


zhidong zhao wrote:
> How to set the marshaller to marshal a globe type into document fragment
string without xml
> prolog or xsi:xxx xmlns:xxx attributes?
>

There is no way to do this via the javax.xml.bind interfaces. We considered
adding
this feature to the 1.0 version of JAXB, but ultimately removed it. You
should be
able to marshal to a custom ContentHandler that strips the start|endDocument
events
out of the SAX stream.

--Ryan Shoemaker, Sun Microsystems, Inc.