menu spec include/exclue rules question

Havoc Pennington hp at redhat.com
Tue Jul 1 23:46:57 EEST 2003


On Tue, Jul 01, 2003 at 10:19:25PM +0200, Heinrich Wendel wrote:
> 
> <And>
>   <Category>Games</Category>
>   <Category>Utilities</Category>
> </And>
> 
> Is this rule the same as "if (category = 'Games' and category = 'Utilities') 
> ..." ?
>

<Category> is a has-a query rather than an '=' query but yes.
"if (has category Games and has category Utilities)"
 
> <Not>
>   <Category>Games</Category>
>   <Category>Utilities</Category>
> </Not>
> 
> Is this rule the same as "if not (category = 'Games' and category = 
> 'Utilities') ..." ?

No, in more detail:

          <varlistentry>
            <term>&lt;Not&gt;</term>
            <listitem>
              <para>
                The &lt;Not&gt; element contains a list of matching
            rules.  If any of the matching rules inside the
            &lt;Not&gt; element matches a desktop entry, then the
            entire &lt;Not&gt; rule does <emphasis>not</emphasis>
            match the desktop entry. That is, matching rules below
            &lt;Not&gt; have a logical OR relationship.
              </para>
            </listitem>
          </varlistentry>

So that is "if not (has category Games or has category Utilities)"

Basically any list of predicates is interpreted as OR, it's also
discussed in the definition of <Include>. The exception obviously is
<And>. The <Or> element is thus redundant and useless for the most
part, though it may make sense as a way to do "parentheses" inside 
another rule list. i.e.:
 <And>
  <Category>Foo</Category>
  <Or>
    <Category>Bar</Category>
    <Category>Baz</Category>
  </Or>
 </And>
So there the "or" is like extra parens in "(Foo and (Bar or Baz))"

<Or> may also contribute to readability in some cases and keep people
from asking why there isn't an <Or>.

Havoc



More information about the xdg mailing list