atom feed4 messages in org.apache.commons.userRe: [Digester] Problem using recursio...
FromSent OnAttachments
Arshika MishraFeb 28, 2007 3:31 am 
Craig McClanahanFeb 28, 2007 3:12 pm 
Arshika MishraMar 1, 2007 9:39 pm 
VikramMar 14, 2007 4:44 am 
Subject:Re: [Digester] Problem using recursion in xml rule file
From:Arshika Mishra (Arsh@lntinfotech.com)
Date:Mar 1, 2007 9:39:14 pm
List:org.apache.commons.user

Hi!!

Thanks for the solution. But actually, problem is more complex. The complete format of the XML file is as follows:

<system-options> <dpr-domain name="abc"> <dpr-data-category name="xyz"> <dpr-attribute> </dpr-attribute> <dpr-data-category name="abc"> <dpr-attribute> </dpr-attribute> <dpr-data-category> </dpr-data-category> </dpr-data-category> </dpr-domain> <dpr-domain name="lmn"> <dpr-data-category name="xyz"> <dpr-attribute> </dpr-attribute> <dpr-data-category name="abc"> <dpr-attribute> </dpr-attribute> <dpr-data-category> </dpr-data-category> </dpr-data-category> </dpr-domain> <status> <status-name/> <status-name/> </status> <password>abc<password> </system-options>

I don't know how to write the xml rule file for parsing the above xml. Even I am not able to implement the solution provided.

Thanks, Arshika

On 2/28/07, Arshika Mishra <Arsh@lntinfotech.com> wrote:

Hi!

I am trying to parse an XML file using digester but getting a problem. The file has a recursive tag. The format of the file given below:

<dpr-domain name="AircraftPerformances"> <dpr-data-category name="AircraftClass" systemOption="FULLOLDI"> <dpr-attribute name="landingSpeed" systemOption="HALFOLDI"/> <dpr-data-category name="holdingParameters" systemOption="HALFOLDI"> <dpr-attribute name="maximumspeed1" systemOption="FULLOLDI"/> </dpr-data-category> <dpr-data-category name="turnRate" systemOption="FULLOLDI,HALFOLDI"> <dpr-attribute name="maximumspeed2" systemOption="FULLOLDI"/> <dpr-data-category name="accelerateRate" systemOption="HALFOLDI"> <dpr-attribute name="maximumspeed21" systemOption="FULLOLDI"/> <dpr-data-category name="descendRate" systemOption="HALFOLDI"> <dpr-attribute name="maximumspeed211" systemOption="FULLOLDI"/> </dpr-data-category> </dpr-data-category> </dpr-data-category> </dpr-data-category> </dpr-domain>

The rule file I have written for this is: <digester-rules> <pattern value="dpr-domain"> <object-create-rule classname="check.Domain"/> <pattern value="*/dpr-data-category"> <object-create-rule classname="check.DataCategory"/> <set-properties-rule/> <pattern value="dpr-attribute"> <object-create-rule classname="check.Attribute"/> <set-properties-rule/> <set-next-rule methodname="addAttributes" /> </pattern> <set-next-rule methodname="addDataCategory" paramtype="check.DataCategory"/> </pattern> </pattern> </digester-rules>

But this is not working. If the "dpr-domain" tag is removed, then it works. Please help me by giving a solution for this problem.

Arshika,

I never use the XML format for defining rules, so I'm a little fuzzy on how it really works. However, it seems to me that you would *not* want to nest your category pattern inside the domain pattern when you use the "*" prefix for recursion. The problem is that the composite pattern will be trying to match "dpr-domain/*/dpr-data-category" and I do not think Digester knows how to deal with wildcards in the middle like that.

Try something along these lines instead:

<digester-rules>

<pattern value="dpr-domain"> ... rules for a new domain ... </pattern>

<pattern value="*/dpr-data-category"> ... rules for a new category ... <pattern value="dpr-data-attribute"> ... rules for a new attribute ... </pattern> </pattern>

</digester-rules>

Craig

Regards, Arshika Mishra

______________________________________________________________________

______________________________________________________________________