commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robert burrell donkin <robertburrelldon...@blueyonder.co.uk>
Subject [digester] Re: defining rules in XML
Date Wed, 23 Apr 2003 13:54:11 GMT
hi marco

please remember to prefix your post with the name of the component that it 
concerns. most developers and committers use mail filters that recognize 
mail about components of interest to them.

i think that you need to add two <call-param-rule> elements after your 
<call-method-rule> to set the parameters to be used for the method call.

i'd say that something like:

      <pattern value="properties/property">
		...
		<call-method-rule  pattern="name" methodname="setProperty" 
paramcount="2" />
		<call-param-rule paramnumber='0' attrname='name'/>
		<call-param-rule paramnumber='1' attrname='name'/>
		...
      </pattern>

should do it. (not that i've tested it so some tweaking might be required.
)

- robert

On Friday, April 18, 2003, at 01:56 PM, <Marco.Mistroni@nokia.com> wrote:

> hi all,	
> 	 i have following XML file
>
> <myproperties>
>   <property name="foo" value="bar"/>
>   <property name="foo2" value="bar2"/>
>   ....
> </myproperties>
>
> and i would like digester to populate a java.util.Properties object
> while parsing, using an XML rule file
>
> but, i m stuck in how to write the proper rule...
> i have written followign but seems not to work....
>
> <?xml version="1.0"?>
>   <digester-rules>
>
>
>      <object-create-rule pattern="myproperties" 
> classname="java.util.Properties" />
>
>      <pattern value="properties/property">
>
>
> 	<!??????? <call-method-rule  pattern="name" methodname="setProperty" 
> paramcount="2" /> -->
>
>
>      </pattern>
>
>
>
>   </digester-rules>
>
> i don't know how to write properly the 'call method rule'....
>
> anyone can help me?
>
> br
> 	marco
>
>
>
>
>
>
>> -----Original Message-----
>> From: ext Baltz, Kenneth [mailto:Kbaltz@firstam.com]
>> Sent: 13 February, 2003 18:50
>> To: Jakarta Commons Users List
>> Subject: RE: Digester question
>>
>>
>>>
>>>
>>> Is it possible to handle duplicate elements in commons
>> digester using
>>> the following example ?
>>
>> Yes.  Digester will fire whatever rules you assign to the
>> given element as
>> many times as that element appears.
>>
>>>
>>>
>>> <phonebook>
>>> 	<entry>
>>> 	 <owner>Owner</owner>
>>> 	 <number>Number</number>
>>> 	 [ and many other numbers to follow..]
>>> 	 </entry>
>>> </phonebook>
>>>
>>> I can handle many <entry> elements but can't quite yet grasp
>>> how to do
>>> the multiple number elements. Does anyone have any idea how
>>> to do this ?
>>
>> It depends on what you want to do with these elements.
>> Originally I was
>> going to say that you handle <number> exactly the way you
>> handle <entry>,
>> there's no difference.  Give us a description of what you
>> would like to have
>> happen and we can tell you how to do it.
>>
>> I'm guessing that you have something like an Entry bean, with an owner
>> property and a numbers property that returns a collection.
>> If you have a
>> method addNumber() in your Entry bean, then just use a
>> SetNextRule() to call
>> addNumber and pass the contents of each <number> to your Entry bean.
>>
>> K.C.
>>
>
> ---------------------------------------------------------------------
> 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