commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Dudziak <>
Subject Re: [betwixt] saving/reading more than one bean in the same xml file
Date Fri, 13 May 2005 16:54:36 GMT
> I tried the checkout and built the latest svn-version. I also tried to
> look into the mentioned test-case, but that did not really helped me.
> In the test case there is one bean holding another bean of different
> type, which is written to and read from the xml file. That already
> worked for me.
> What i try to do is, i have several beans of the same type (e.g.
> TestBean) and i would like to store all of them in the same xml file.
> This will not work because of not-wellformed xml:
> <?xml version='1.0' ?>
>   <testBean1>
>     <description>TestDescription</description>
>   </testBean1>
>   <testBean2>
>     <description>TestDescription</description>
>   </testBean2>
>   <testBean3>
>     <description>TestDescription</description>
>   </testBean3>
> What i want to do is having several beans of the same (or different)
> type in one xml file and tell betwixt with a construct like:
> beanReader.registerBeanClass("testBean" + i, AdditionalBean.class);
> that it should take the named bean out of that file.
> Isn't there any type of "dummy-container" where i can put all my bean
> data into and getting it out by telling betwixt the name i like to have?
> (simply to get wellformed xml file)
> e.g.:
> <?xml version='1.0' ?>
> <dummyContainer>
>   <testBean1>
> [...]
>   </testBean3>
> </dummyContainer>
> That would be very easy and i wonder if this issue is so hard for me to
> solve :(
> Still trying to get a solution,

Might be easiest if you use a simple container class that holds the instances.
However I wonder how you differenciate the TestBean instances ? If
they are contained in a collection, then I think you should rather use
Digester directly, this gives you more freedom though also requires a
bit more work.
If there is a fixed number of TestBean instances to persiste, you
should define a simple container that has the corresponding number of
properties. You could even use a DynaBean for the purpose of the
container if you are unwilling to introduce a class solely for the
purpose of XML reading/writing of your TestBeans.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message