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] - how to Parse Tag attributes and tag content with addObjectCreate and CallMethod...
Date Tue, 13 Apr 2004 06:07:23 GMT
Hi,

On Tue, 2004-04-13 at 17:33, Francis.LeMonnier@genedata.com wrote:
> I am trying to set up the parse rules for an xml entry of the following 
> type: 
> <Root> 
>   <subSection> 
>     <id>7</id>	 
>       <Item Name="forProperty" Type="String">This is the 
> Content</Item>  
>       <Item Name="forAnotherProperty" Type="String">More 
> Content</Item>  
>   </subSection> 
> </Root> 
> I want to achieve the equivalent of SubSection.setForProperty 
> with the value  "This is the Content" and 
> SubSection.setAnotherProperty with "More  Content". 
> How do I do this? 

I believe you'll have to write your own rule. What you need is a variant
of the SetPropertyRule.

SetPropertyRule is very similar to what you want, except that it takes
data like this:
  <Item Name="forProperty" Value="This is the context"/>

If you can change your input xml to be like SetPropertyRule expects,
that would probably be a good idea.

Or the SetNestedPropertiesRule (which is currently only available in
nightly builds) can be used to do this:
  <forProperty Value="This is the context"/>

Note that neither take a "type" parameter; they try to automatically
convert the input string to the appropriate type for the target bean
property.

If you are determined to use the format you describe in your email, then
it isn't that big a deal to write your own Rule class. I can provide you
with some hints on that if you need them.

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