Hello,
I'm using the Commons Digester, specifically, to read data from XML files in
order to create objects and I later use Betwixt to write objects out to XML.
I'm using Digester "rules" files to specifiy XML layout so a known pattern is
used while reading and creating objects.
What I'm trying to figure out is how to make Betwixt write out information
from an object in the same way that the Digester expects when reading (that
is, so it matches according to the rules file that I have).
For example, I have a rules file set up for a class called "Skill":
<digester-rules>
<pattern value="skill">
<object-create-rule classname="src.gov.ohio.jfs.model.Skill" />
<bean-property-setter-rule pattern="name"/>
<bean-property-setter-rule pattern="acquiredDate"/>
<bean-property-setter-rule pattern="updateDate"/>
<pattern value="experience">
<object-create-rule
classname="src.gov.ohio.jfs.model.Experience" />
<set-properties-rule />
<set-next-rule methodname="setExperience" />
</pattern>
<set-next-rule methodname="addSkill" />
</pattern>
</digester-rules>
An example XML file corresponding to a Skill would appear like so:
<skill>
<name>COBOL</name>
<acquiredDate>2/8/1985</acquiredDate>
<updateDate>1/19/2006</updateDate>
<experience>
<level>10</level>
<description>Adept</description>
</experience>
</skill>
If I modify the instance that is created after reading the file containing
the sample data above and then use Betwixt to write out the updated info
afterwards, I see the following:
<skill>
<acquiredDate/>
<experience>
<description>Adept</description>
<level>10</level>
</experience>
<name>JCL</name>
<updateDate/>
</skill>
How can I instruct Betwixt (the BeanWriter instance, I think) to write out
the info so that it matches the pattern that I'm using when reading? Perhaps
I should just be using Betwixt for both reading and writing, but I'd still
like to be able to set things up, explicitly, so that the XML format for a
given class is knowing ahead of time (so the format for reading and writing is
the same).
Please reply, if someone has an idea about this. Thanks!
Jeff
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com