commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Arshika Mishra <Arshika.Mis...@lntinfotech.com>
Subject Re: [Digester] Problem using recursion in xml rule file
Date Fri, 02 Mar 2007 05:39:37 GMT
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 <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
>
>
>
> ______________________________________________________________________

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