Hi Tamas,

You need to go to either the MarshallingContext implementation class for IMarshallingContext, or to the IXMLWriter in order to control writing start and end tags. The IMarshallingContext marshalDocument() JavaDocs say:

/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()./

which gives the general idea of the process, but doesn't tell you how to control the bit in between. Here's how you'd do what you want using the IXMLWriter approach - First call startDocument(), then get the IXMLWriter by calling getWriter(). Call startTagClosed() on the writer to write the root element start tag, then just marshal the child objects normally. When you're done with the child objects, call endTag() to close the root element, and finish with a call to the IMarshallingContext endDocument() method.

The namespace index used by both the MarshallingContext and IXMLWriter element and attribute methods is generated from your binding. The no-namespace index is always 0, so if you're not using namespaces just always use 0. If you *are* using namespaces and want to be safe, you need to lookup the namespace in the array of namespace URIs from the IBindingFactory (the index passed to the methods is the same as the index into the array).

 - Dennis


Tamas Hegedus wrote:

Hi,

I could not find the way of marshalling individual objects.
The opposit of the following marshalling:
while( !umc.isEnd()) {
   ABCtop s = (ABCtop) umc.unmarshalElement();
   s.setId( new Integer(cnter));
   s.dosomething();
}

I would like to write a root tag (opposite of umContext.parsePastStartTag( nameSpace, rootTag);)
Then I would like to marshall several objects.
Finally write an end root tag.

======
I tried the MarshContext.marshalDocument(...), but it writes only an xml start tag, one object, then closes the output stream.

Thanks a lot!

===================================
To my prev emails to Mocky and Dennis: db4o has memory leakage problems (and I had several million objects...)

Regards,
Tamas



-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.  Get Certified Today
Register for a JBoss Training Course.  Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to