commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simon <simon.kitch...@chello.at>
Subject Re: [Digester] Generic digester patterns?
Date Thu, 02 Aug 2007 15:27:33 GMT
On Thu, 2007-08-02 at 16:55 +0200, Ernst de Haan wrote:
> I'm struggling to implement generic digester patterns. Some hints or  
> references to appropriate examples would be much appreciated!
> 
> This is my input XML:
> 
> -----------------------
> <Config>
>    <backgroundColor>
>      <Color r="0" g="0" b="0" />
>    </background>
>    <axisColor>
>      <Color r="76" g="0" b="76" />
>    </axisColor>
> </Config>
> -----------------------
> 
> and these are my Digester rules:
> 
> -----------------------
> <pattern value="*/Color">
>    <factory-create-rule classname="ColorFactory" />
> </pattern>
> 
> <pattern value="Config">
>    <object-create-rule classname="Config">
>    <set-nested-properties-rule />
> </pattern>
> -----------------------
> 
> The factory is accessed properly, but I cannot get Digester to bind  
> the result of the "*/Color" rule set (a java.awt.Color object) so it  
> gets associated with the Config object.

See the javadoc for SetNestedPropertiesRule.
http://commons.apache.org/digester/commons-digester-1.8/docs/api/org/apache/commons/digester/SetNestedPropertiesRule.html

As noted in the javadoc it only supports "primitive" nested properties.
Once a SetNestedPropertiesRule matches, no other rules fire beneath it.

So in your case, rather than using SetNestedPropertiesRule you'll need
explicit rules to handle Config/background and Config/axisColor.

Regards,

Simon


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


Mime
View raw message