commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig McClanahan" <craig...@apache.org>
Subject Re: [Digester] Problem using recursion in xml rule file
Date Wed, 28 Feb 2007 23:12:24 GMT
On 2/28/07, Arshika Mishra <Arshika.Mishra@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
>
>
>
> ______________________________________________________________________

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message