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

All > Relax NG > Simplification - optional element > Test 136

Previous sample | Next sample

Author: James Clark
Origin: Testsuite for Relax NG


ElementsAttributes
elementname |
empty
optional

ZVON comment: Element "foo" must have just 0 or 3 "bar" children 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" >
     <optional>
          <element name="bar">
               <empty/>
          </element>
          <element name="bar">
               <empty/>
          </element>
          <element name="bar">
               <empty/>
          </element>
     </optional>
</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>

Valid document:
<foo/>

Invalid document:
<foo>X</foo>

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

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