users@jaxb.java.net

Re: Marshalling and unmarshalling to several root elements

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Fri, 09 May 2003 11:02:27 -0700

> I try to combine it with the chain transformation example from Xalan's
> website ( http://xml.apache.org/xalan-j/samples.html#pipe ).
>
> The pipe example requires an InputSource.
>
> Since JAXBSource is a SAXSource (according to the Javadoc), it should
> be able to return an InputSource when I use getInputSource().

I see what you are doing.


The rule of thumb of using JAXBSource is that you are not supposed to
use its methods. You just pass it to wherever it expects Source.

In this particular example, what you want to do is to marshal a JAXB
content tree to SAX events (so that you can pass it to
TransformerHandler). Thus you don't even need to use JAXBSource.

Instead of :

          reader.parse("foo.xml");

Just say:

          marshaller.marshal( yourJaxbObject, tHandler1 );


In some sense your bug report is more like a doc bug. A document could
be clarified to stress the point that you are not supposed to call methods
on it.

regards,
--
Kohsuke KAWAGUCHI                  408-276-7063 (x17063)
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com