Hi Dennis,

I always forget about direct class-cast to the
marshalling/unmarshalling interfaces, sorry about not being a good
student ;-)

You however would have to perform the checks that are otherwise done
by the marshalling context...

Regarding the reading back, I personnaly use a reader that fakes the
parser into thinking the string has a root element.
Then I use the currentEvent() and next() methods of the unmarshalling
context to unmarshall the objects into a list.

I had little choice over that, because of a migration from castor API,
and I had to keep those objects backward compatible. They are also
stored in a database, and the root tags are nothing but storage
overhead in my case.

Francois.

On 9/28/07, Dennis Sosnoski <[EMAIL PROTECTED]> wrote:
> Hi Francois,
>
> That will work, but you can actually get the equivalent effect without
> needing to modify the supplied code.
>
> The IUnmarshallingContext and IMarshallingContext setup calls are all
> modular, and the JavaDocs spell out the effects of the different calls
> to point you in the direction of doing your own compositions. So the
> three-argument marshalDocument() call, for instance, says:
>
> /Marshal document from root object. This can only be validly called
> immediately following one of the set output methods; otherwise the
> output document will be corrupt. The effect of this method is the same
> as the sequence of a call to startDocument(java.lang.String,
> java.lang.Boolean), a call to marshal the root object using this
> context, and finally a call to endDocument()./
>
> This doesn't spell it out, but what do you suppose would happen if
> rather than calling this method you instead called startDocument(),
> followed by multiple calls to marshal objects, followed by the
> endDocument() call? The result wouldn't be valid XML (since you'd have
> more than one root element in the "document"), but it would be what you
> want.
>
> One thing that's not spelled out in the interface is how you actually
> marshal an object directly. This is really simple, though. Any class
> with a concrete mapping gets the IMarshallable interface added by the
> binding compiler. You just need to cast your instance object to this
> interface and use that for the marshalling call.
>
> But once you have your output with the multiple XML documents
> concatenated together you're going to have a problem reading it back in,
> since the unmarshalling side expects to work with individual documents
> (and since the parsers enforce this requirement, it's not something that
> can be changed by the unmarshalling code). What are you doing for this?
>
>  - Dennis
>
> Dennis M. Sosnoski
> SOA and Web Services in Java
> Training and Consulting
> http://www.sosnoski.com - http://www.sosnoski.co.nz
> Seattle, WA +1-425-939-0576 - Wellington, NZ +64-4-298-6117
>
>
>
> Francois Valdy wrote:
> > I'm doing so with a little trick:
> > instead of a GenericXMLWriter (for instance), use the following:
> >
> > GenericXMLWriter writer = new GenericXMLWriter(namespaces){
> >                 @Override
> >                 public void close() throws IOException
> >                 {
> >                     // no close
> >                 }
> >             };
> >
> > Then you'll be able to call several times mctx.marshalDocument(...) in
> > a loop, thus marshalling all your objects to the same stream.
> >
> > I'm not sure this behavior is intented to be used, but it's a huge
> > performance gain too (re-use the same context).
> >
> > Cheers,
> > Francois.
> >
> > On 9/26/07, Dan Shuhler <[EMAIL PROTECTED]> wrote:
> >
> >> Hi,
> >>
> >> Is it possible to use JiBX to marshal more than one object into a single 
> >> XML
> >> file?  I have a large quantity of objects I need to marshal.  Currently, I
> >> am putting them all into a container object and marshalling that, but
> >> loading so many objects at once puts a heavy strain on the system.  I would
> >> prefer to load an object, marshal that data, load the next object, marshal
> >> that data, etc.
> >>
> >> I have not been able to find a way to marshal an object without have an XML
> >> header printed at the top and my output stream being closed.  Is there
> >> something I am missing?  Or is JiBX not intended for this?
> >>
> >> Thanks for your help,
> >> Dan
> >>
> >> ________________________________
> >> Pinpoint customers who are looking for what you sell.
> >>
> >>
> >> -------------------------------------------------------------------------
> >> This SF.net email is sponsored by: Microsoft
> >> Defy all challenges. Microsoft(R) Visual Studio 2005.
> >> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> >> _______________________________________________
> >> jibx-users mailing list
> >> jibx-users@lists.sourceforge.net
> >> https://lists.sourceforge.net/lists/listinfo/jibx-users
> >>
> >>
> >>
> >
> > -------------------------------------------------------------------------
> > This SF.net email is sponsored by: Microsoft
> > Defy all challenges. Microsoft(R) Visual Studio 2005.
> > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> > _______________________________________________
> > jibx-users mailing list
> > jibx-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/jibx-users
> >
> >
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2005.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> jibx-users mailing list
> jibx-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jibx-users
>

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to