commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Marendo <>
Subject Roundtripping using Digester and Betwixt
Date Fri, 18 Aug 2006 20:19:54 GMT
  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":
      <pattern value="skill">
          <object-create-rule classname="" />
          <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="" />
              <set-properties-rule />
              <set-next-rule methodname="setExperience" />
          <set-next-rule methodname="addSkill" />
   An example XML file corresponding to a Skill would appear like so:
  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:
  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!
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message