Daniel Veillard <veillard@redhat.com> wrote on 10/06/2010 12:00:04 PM:

> Re: [libvirt] [patch 4/5] nwfilter: Extend schema to accept state attribute

>
> On Fri, Oct 01, 2010 at 08:28:53PM -0400, Stefan Berger wrote:
> > Extend the nwfilter.rng schema to accept state attributes.
> >
> > Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
> [...]
> > +
> > +  <define name='stateflags-type'>
> > +    <data type="string">
> > +      <param name="pattern">((NEW|ESTABLISHED|RELATED|INVALID)(,
> (NEW|ESTABLISHED|RELATED|INVALID))*|NONE)</param>
> > +    </data>
> > +  </define>
> >  </grammar>
>
> Hum, we really want to accept something like
>    NEW,NEW,NEW,NEW
> ?
> I understand that we may want to add RELATED to another state, but that
> regexp could probably be refined, isn't it ?


The only solution that I could come up with is to explicitly enumerate all possible
combinations of the above 4 words (15 combinations). This solution would then also
force the user to provide them in a particular order:

(A)|(B)|(C)|(D)|(A,B)|(A,C)|(A,D)|(B,C)|(B,D)|(C,D)|(A,B,C)|(A,B,D)|(A,C,D)|(B,C,D)|(A,B,C,D)

When not forcing the user into a sequence we'd need something like this here:

(A)|(B)|(C)|(D)|(A,B)|(A,C)|(A,D)|(B,C)|(B,D)|(C,D)|(A,B,C)|(A,B,D)|(A,C,D)|(B,C,D)|(A,B,C,D)|
                (B,A)|(C,A),(D,A),(C,B),(D,B),(D,C),(A,C,B)|(A,D,B)|(A,D,C)|(B,D,C)|(A,B,D,C)|
                ...

I think the proposed solution is not as 'strict' as it should be but compared to the other two
solutions I think it is 'ok' -- unless there is a fundamentally different way of writing this
type of regex.

Regards,
   Stefan