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

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

Previous sample | Next sample

Author: James Clark
Origin: Testsuite for Relax NG


ElementsAttributes
definename |
elementname |
empty
grammar
refname |
start

ZVON comment: Element "foo" must have exactly three "bar" children and nothing else.

Correct schema

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


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>