[Digester] Matching depth with wildcard parent elements ?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Digester] Matching depth with wildcard parent elements ?

Thomas Dudziak
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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

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

Simon Kitching
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: [hidden email]
For additional commands, e-mail: [hidden email]