[relaxng-user] Re: [relax-ng-comment] common-atts

Murata Makoto EB2M-MRT at asahi-net.or.jp
Wed Sep 24 08:13:20 ICT 2003


> This may become a FAQ. What's the difference between empty and
> notAllowed in this context? Are they ever interchangeable? Would it
> mean the same if I said this?
>   <define name="class.filter">
>     <empty/>
>   </define>

No, <empty/> and <notAllowed/> are not interchangeable.

If you write <element name="foo"><empty/></element>, you allow
<foo></foo>.  If your write <element name="foo"><notAllowed/></element>,
you allow nothing.

In the case of your example, use of <empty/> for class.filter 
means that <element name="foo"><ref name="class.filter"/></element>
allows <foo></foo>.

Some analogy might help to understand <notAllowed/> and <empty/>.
The former is similar to 0 and the latter is similar to 1.
<choice> is simliar to "+".  E.g., 

0 + x = x    <choice><notAllowed/> p1 </choice> = p1

<group> is similar to "*". E.g.., 

0 * x = 0    <group><notAllowed/> p1 </group> = <notAllowed/>

1 * x = x    <group><empty/> p1</group> = p1

Just like 1+x cannot be simplified, <choice><empty/> p1 </choice> 
cannot be simplified.

Hope this helps.

Cheers,

Makoto


More information about the relaxng-user mailing list