Thanks Robert,
Here is more code. I think I am doing the right things, just that this
element has body as well as attribute and that is messing me up :-(
I have 5 classes (Row, Column, Rows, Colums, Report) all the methods are
getting called correctly.
Object Row has one attribute (colnum) and body (which I set to setData)
Once row is created (both attribute and body), I need to add that Row object
in to Object Rows, by addRows() call on Rows. The problem is, colnum gets
set, then it calls addRow (on Rows) and then setData on Row. When it calls
setData, the clonum info ir right. But since order is messed up it has
problems. BTW: columns part is working fine!
Thanks
Shailesh
--------------------------------
Digester digester = new Digester();
digester.setValidating(false);
digester.addObjectCreate("fxf/report", Report.class );
digester.addObjectCreate("fxf/report/table/tr", Rows.class );
digester.addObjectCreate("fxf/report/column_desc", Columns.class );
digester.addObjectCreate("fxf/report/column_desc/col", Column.class );
digester.addObjectCreate("fxf/report/table/tr/td", Row.class );
digester.addCallMethod("fxf/report/table/tr/td", "setData", 0); // Row class
digester.addSetProperties("fxf/report/table/tr/td", "colnum", "column"); //
Row class
digester.addSetProperties("fxf/report/column_desc/col", "colnum",
"columnName"); // Column Class
digester.addSetProperties("fxf/report/column_desc/col", "fieldname",
"columnValue"); // Column class
digester.addSetNext("fxf/report/column_desc/col", "addColumn"); // Columns
class
digester.addSetNext("fxf/report/column_desc", "setColumns"); // Report class
digester.addSetNext("fxf/report/table/tr/td", "addRow"); // Rows class
digester.addSetNext("fxf/report/table/tr", "addRows"); // Report Class
Report rp = (Report)digester.parse(con.getInputStream());
-------------------------------
<?xml version="1.0" encoding="ISO-8859-1" ?>
<fxf version="1.0" data="hold">
<report records="1" lines="1" columns="18" rows="1">
<target format="" version="" type=""
destination="HOLD" />
<column_desc>
<col colnum="c0" fieldname="NSN" />
<col colnum="c1" fieldname="DODAAC" />
</column_desc>
<table>
<tr linetype="data" linenum="1">
<td colnum="c0">8405000011551</td>
<td colnum="c1">R21605</td>
</tr>
</table>
</report>
</fxf>
-----Original Message-----
From: robert burrell donkin [mailto:[EMAIL PROTECTED]
Sent: Thursday, May 05, 2005 2:18 PM
To: Jakarta Commons Developers List
Subject: Re: digester question
On Thu, 2005-05-05 at 12:48 -0400, shailesh.ligade wrote:
> I have a simple xml
>
> <tr>
> <td colnum="c0">7</td>
> <td colnum="c1">8</td>
> </tr>
>
> I have class called Row and and another Rows
>
> Row class has two mthods (one for column and one for data)
> and Rows class has addRow(Row row) method
>
> code is
>
> digester.addSetProperties("tr/td", "colnum", "column");
> digester.addCallMethod("tr/td", "setData", 0);
>
> and
>
> digester.addSetNext("tr/td", "addRow");
>
> What i get in system.out inside addRow is c0 - null so so my data is
always
> null. Actaully setData() method is getting called, but it is called after
> addRow() method.
>
> How to fix this?
there are probably a couple of difficulties here.
the first is that i don't see an object creation rule. you may need to
add a rule to create the row. (see documentation for more details on the
choices.)
the second is that you're going to need to think about the ordering of
your rules. again, take a look at the documentation for more details.
if this doesn't help then i'd suggest posting a longer code snippet: one
that people can run. it's generally easier to diagnose things that way.
- robert
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
�
Attention:
Any views expressed in this message are those of the individual sender, except
where the message states otherwise and the sender is authorized to state them
to be the views of any such entity. The information contained in this message
and or attachments is intended only for the person or entity to which it is
addressed and may contain confidential and/or privileged material. If you
received this in error, please contact the sender and delete the material from
any system and destroy any copies.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]