You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Simone Tripodi <si...@apache.org> on 2014/03/01 08:29:07 UTC

Re: [digester] XML rules, set-properties-rule, and ignoring missing properties

Hi Paul,

thanks a lot for reporting, very appreciated. Can you fill a JIRA issue for
that?

As a Digester best practice, I suggest you to not go through the XML rules
definition but, if you need a more compact way to express rules, refer to
rules binder, which is pretty faster than mapping the XML document to rules.

HTH, best,
-Simo

[1] http://commons.apache.org/proper/commons-digester/guide/binder.html

http://people.apache.org/~simonetripodi/
http://twitter.com/simonetripodi


On Fri, Feb 28, 2014 at 5:57 PM, paul anderson <pa...@yahoo.com>wrote:

> The javadoc on SetPropertiesRule:
> >>isIgnoreMissingProperty()>>            Are attributes found in the xml
> without matching properties to be ignored?
>
>
>  implies that one should be able to write a rule such as
>
> ***<set-properties-rule ignoreMissingProperty="true"/>***
>
> or
> ***<set-properties-rule ignoreMissingProperties="true"/>***
>
>
> but obviously these don't work.
>
> Surely it's a common use-case to want to digest arbitrarily complex XML
> without needing to specify one by one every attribute you don't care about?
>
> Requiring a user to catalog an exhaustive set of attributes all over their
> digester rules creates an extraordinary burden and would also clutter the
> rules as to make them near unreadable.
>
> Unless memory fails me, Digester used to silently ignore missing
> properties, so it seems we've lost something since then. Seems that either
> of the options marked *** would be a better solution than having scores of
> ignore-elements all over the place:
>
>     <set-properties-rule>
>       <ignore attr-name="Id"/>
>       <ignore attr-name="Address"/>
>       <ignore attr-name="email"/>
>       <ignore attr-name="favoriteBreakfast"/>
>       <ignore attr-name="likesApples"/>
>       <ignore attr-name="likesPeaches"/>
>     </set-properties-rule>
>
>
> What is more, when the XML schema is extended to add attributes (common
> occurrence) this pattern of "fail unless explicitly ignored" causes a
> maintenance nightmare.