commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maurizio Cucchiara <mcucchi...@apache.org>
Subject Re: Digester rules problem.
Date Thu, 06 Oct 2011 10:38:07 GMT
Hi Simo,
looking at the http://s.apache.org/OQ0 I realized that Digester uses
an xpath-like string, I am wondering if there is a way (or a rule)
which allows using full xpath syntax (Eric could have used something
like "response/attribute[@name='ip' ]").
Is there any Rule implementation about this specific topic?


Maurizio Cucchiara



On 6 October 2011 09:40, Simone Tripodi <simonetripodi@apache.org> wrote:
> Hi Eric,
> I can provide you the solution but I'll be busy for the whole morning.
> Please wait I'll send you the hints ASAP.
> All the best,
> Simo
>
> http://people.apache.org/~simonetripodi/
> http://www.99soft.org/
>
>
>
> On Thu, Oct 6, 2011 at 5:02 AM, Eric Chow <eric138@gmail.com> wrote:
>> Hello,
>>
>>
>>
>> <response query="10.70.0.2,v2p,3,1,0" result="true">
>>
>>    <attribute name="ip">10.70.0.2</attribute>
>>
>>    <attribute name="slot">3</attribute>
>>
>>    <attribute name="port">1</attribute>
>>
>>    <attribute name="status">active</attribute>
>> </record>
>>
>>
>>
>> In the above XML, I have a bean as following:
>>
>> public class Response {
>>   private String query;
>>   private boolean result;
>>
>>   private String ip;
>>   private String slot;
>>   private String port;
>>   private String status;
>>
>>   ....
>>
>> }
>>
>>
>>
>>
>> For the query, result,  I can easy to use the following codes to parse.
>>
>> Digester digester = new Digester();
>> digester.setNamespaceAware( true );
>> digester.setXIncludeAware( true );
>>
>> digester.addObjectCreate( "response", Response .class );
>> digester.addSetProperties( "response", "query", "query" );
>> digester.addSetProperties( "response", "result", "result" );
>>
>>
>>
>>
>>
>> But, how can I set those <attribute/> into the related properties?
>>
>> Please help.
>>
>> Thanks.
>> Eric
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

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


Mime
View raw message