Hi,

thanks for taking time to explain this in more detail. Let me try to
provide you an answer with.

Basically, Castor's Marshaller is state-less in the sense that it dies
not maintain any state between invocations of the marshal() method(s).
As such, whatever you pass to e.g. the java.io.Writer being passed to
the Marshaller instance is being written out as XML. As such, there's no
solution to your problem from within Castor XML.

Having said that, there's nothing that prevents you from passing the
very same writer to Castor again (and again). If you e.g. used a
StringWriter instance, you can definitely pass it to Castor many times,
and Castor will happily append whatever it produces during marshalling
to the StringWriter.

I hope this helps.

Regards
Werner
Castor, committer

Chayssiv wrote:
> 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
>>
>>
>>
>>
> 


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to