ZVON > References > Zvon Example Repository
Example repository: index | categories | search

All > Relax NG > Simplification - number of child elements > Test 144

Previous sample | Next sample

Author: James Clark
Origin: Testsuite for Relax NG


ElementsAttributes
elementname |
empty
group

ZVON comment: The element "foo" must have exactly three "bar" elements and nothing else.

Correct schema

<element name="foo" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns="http://relaxng.org/ns/structure/1.0" >
     <group>
          <element name="bar">
               <empty/>
          </element>
          <element name="bar">
               <empty/>
          </element>
          <element name="bar">
               <empty/>
          </element>
     </group>
</element>


Valid document:
<foo>
     <bar/>
     <bar/>
     <bar/>
</foo>

Invalid document:
<foo>
     <bar/>
     <bar/>
     <bar/>
     <bar/>
     <bar/>
     <bar/>
</foo>

Invalid document:
<foo>
     <bar/>
     <bar/>
</foo>

Invalid document:
<foo>
     <bar/>
</foo>

Invalid document:
<foo/>

Invalid document:
<foo>X</foo>

Invalid document:
<foo>
     <bar/>X
     <bar/>
     <bar/>
</foo>

Invalid document:
<foo>
     <bar/>
     <bar/>
     <bar/>
     <bar/>
</foo>