commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "HernĂ¡n Seoane" <hseo...@gmail.com>
Subject Help with Digester xmlrules to create a complex object
Date Wed, 05 Jul 2006 22:29:24 GMT
Hello,  I'm having some trouble with Digester when trying to create a
"complex" object from the following xml:

<Competition>
       <CompetitionName>Competition</CompetitionName>
       <PrizeOnOffer>2000</PrizeOnOffer>
       <WinnerFirstName>Name</WinnerFirstName>
       <WinnerLastName>LastName</WinnerLastName>
       <WinnerTown>Town</WinnerTown>
</Competition>

My xmlrules are:

<digester-rules>
 <pattern value="Competition">
  <object-create-rule classname="Competition" />
  <call-method-rule pattern="CompetitionName"
methodname="setCompetitionName" paramcount="0" />
  <call-method-rule pattern="PrizeOnOffer" methodname="setPrizeOnOffer"
paramcount="0" />

  <object-create-rule classname="Contestant" />
  <call-method-rule pattern="WinnerFirstName" methodname="setFirstName"
paramcount="0" />
  <call-method-rule pattern="WinnerLastName" methodname="setLastName"
paramcount="0" />
  <call-method-rule pattern="WinnerTown" methodname="setTown" paramcount="0"
/>
  <set-next-rule methodname="setWinner" paramtypes="Contestant" />
 </pattern>
</digester-rules>


My Competition object has a Contestant attribute, and what I'm trying to do
is to set the Contestant to the Competition object, but it's not working, as
the information for both objects is at the same level in the DOM structure,
I'm receiving the following error:

*No such accessible method: setCompetitionName() on object:
com.smg.copland.model.Contestant*

The XML file I'm reading cannot be modified, so I cannot change the
structure to nest properties. Any ideas?
Thanks in advance,

Hernan Seoane

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message