You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Thomas Dudziak <to...@gmail.com> on 2005/05/16 00:08:49 UTC

[Digester] Matching depth with wildcard parent elements ?

Is it possible to match the depth of an element but without specifying
the parent elements ? E.g.

a/b/c

matches c at depth 3 whereas

*/c

matches c at any depth. But if I want to match c specifically at depth
3 whatever elements are its parent, I'd like to do something like

?/?/c

Is this possible, and if, how ?

regards,
Tom

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


Re: [Digester] Matching depth with wildcard parent elements ?

Posted by Simon Kitching <sk...@apache.org>.
On Mon, 2005-05-16 at 00:08 +0200, Thomas Dudziak wrote:
> Is it possible to match the depth of an element but without specifying
> the parent elements ? E.g.
> 
> a/b/c
> 
> matches c at depth 3 whereas
> 
> */c
> 
> matches c at any depth. But if I want to match c specifically at depth
> 3 whatever elements are its parent, I'd like to do something like
> 
> ?/?/c
> 
> Is this possible, and if, how ?

The standard BaseRules matching engine definitely doesn't support this.
I don't believe the ExtendedBaseRules matching engine does either.

The RegExRules matching engine can probably be used to do what you want.
However using this rules engine will obviously require all the other
rule patterns to be "regex rules" rather than normal ones. Note also
that the RegExRules class is slower than the standard RulesBase class; I
don't know whether this is relevant to your application or not.

If it is only a few patterns that you need this behaviour for, then it
might be worth writing a "filter" rule, which takes another rule as a
target and only invokes the target rule begin/body/end methods when the
condition is right (eg digester.getMatch() has three / characters).

Regards,

Simon


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