commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Kitching <skitch...@apache.org>
Subject Re: [Digester] Matching depth with wildcard parent elements ?
Date Sun, 15 May 2005 23:54:40 GMT
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


Mime
View raw message