commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Kitching <si...@ecnetwork.co.nz>
Subject Re: Digester: Problem of loading parents attribute to the child
Date Fri, 08 Oct 2004 00:11:11 GMT
On Fri, 2004-10-08 at 07:11, Nalika Dissanayaka wrote:
> Hi,
> 
> I am having a difficulty to load the following XML file by using the
> commons Digester. Is there anyone that can help me on this...
> 
> XML FILE
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <metadata lang="en-US" environment="Production" revision="001">
>        <Sender>
>                <Name>my nameDC</Name>
>                <Address>my address </Address>
>        </Sender>
>        <DataArea>
>                <Data Set>
>                        <Data>
>                                <attr1></attr1>
>                                <attr2></attr2>
> 
>                                <attrn></attrn>
> 
>                        </Data>
>                        <Data>
>                                <attr1></attr1>
>                                <attr2></attr2>
> 
>                                <attrn></attrn>
>                        </Data>
>                </Data Set>
>        </DataArea>
> </metadata>
> 
> I am only interested getting the list of "Data" objects. The issue is,
> Data class has a attribute  called "lang" which should be loaded from
> the value of the "lang" in the "metadata" node. (I am planning to load
> series of files where metadata lang can be changed based on the
> locale)
> 
> What are the possible approaches that I can use ?. Is this something
> that can be done by using the commons Digester. (I have no problrm of
> loading the list of "Data")

It certainly can be done using the Digester, though you might have to
create a custom Rule class or two.

I would suggest having a look at the ObjectParamRule class which can be
used to pass an arbitrary object to a method on the top object on the
digester object stack.

Regards,

Simon


---------------------------------------------------------------------
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