Why cant you use a file operation to append ? Marshall what you want to append, 
into a string and then append. Or open the file in append mode and do it. If 
you have to deal with root elements or positioning or large file, then use a 
RandomAccessFile...

-- pady



> Date: Tue, 1 Apr 2008 17:10:03 -0700
> From: [EMAIL PROTECTED]
> To: [email protected]
> Subject: Re: [castor-user] append to a marshaled xml file
> 
> 
> Hi,
> 
> Your observation is correct. But I was trying to seek a way without
> unmarshalling and re-marshalling as the xml would deal with thousands of
> method call inputs. Unmarshaling such huge data and filling the list could
> put memory constraints. 
> 
> My scenario is as follows:
> 
> I have some 6 methods that could be called n number of times in any order at
> any point of time in a day. I have to marshal the inputs from the method
> called onto the xml. Suppose that method 1 is called in the start of the day
> and it's object has been already marshaled into xml. 
> By overwriting what I meant was that when method 2 is called later, simply
> marshal(method2 object) would result in loss of method 1 's data in the xml
> as castor is making a fresh write of method 2's object onto the xml. Hence I
> wanted to know if I could simply append method 2's object without disturbing
> the already written method 1 object. (mapping.xml covers mapping for all the
> methods)
> 
> Please let me know if this is still not clear. Thanks in advance.
> 
> 
> Werner Guttmann wrote:
> > 
> > Hi,
> > 
> > can you please elaborate a bit more on what you are trying to do ? It 
> > simply is not clear to me what you are trying to achieve.
> > 
> > A few observations:
> > 
> > a) In order to be able to process the list of items in code, you first 
> > need to unmarshal from the XML (using Unmarshaller).
> > b) Once you've got your object (instance) hierarchy, you can modify the 
> > list's content using any of the methods of java.util.List.
> > c) Once you are done with your modifications, simply marshal your object 
> > instance(s) to XML.
> > 
> > In your question you are referring to 'and not overwrite the existing 
> > content'. That statement does not make any sense to me.
> > 
> > Regards
> > Werner
> > 
> > Chayssiv wrote:
> >> Hi, I have an xml file generated by marshaling a java class (using Castor
> >> mapping). The class contains a list of items. As and when the list gets
> >> filled up I would like to APPEND the new data in the class to the already
> >> marshaled xml file (and not overwrite the existing contents of the
> >> marshaled
> >> xml file). Can this be done using Castor? If yes how can it be achieved?
> >> Thanks.
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe from this list, please visit:
> > 
> >     http://xircles.codehaus.org/manage_email
> > 
> > 
> > 
> > 
> 
> -- 
> View this message in context: 
> http://www.nabble.com/append-to-a-marshaled-xml-file-tp16399131p16432024.html
> Sent from the Castor - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
> 
>     http://xircles.codehaus.org/manage_email
> 
> 

_________________________________________________________________
Use video conversation to talk face-to-face with Windows Live Messenger.
http://www.windowslive.com/messenger/connect_your_way.html?ocid=TXT_TAGLM_WL_Refresh_messenger_video_042008

Reply via email to