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

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

Previous sample | Next sample

Author: James Clark
Origin: Testsuite for Relax NG


ElementsAttributes
elementname |
empty
name

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

Correct schema

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