#473 Spurious validation error

v8.6.1
closed
5
2012-10-08
2006-02-22
Michael Kay
No

Given a content model of

<xs:choice maxOccurs="2">
  <xs:element name="el1" type="xs:string"

minOccurs="0"/>
<xs:element name="el2" type="xs:string" minOccurs="0"/>
</xs:choice>

Saxon reports the content <el1/><el2/> as invalid.

The problem here is that there's a sort-of-ambiguity in
the grammar: the validator is deciding that the first
occurrence of the choice is empty, the second
occurrence is <el1/>, and the <el2/> is therefore the
third occurrence and violates maxOccurs="2".

The solution seems to be to rewrite the grammar as

<xs:choice minOccurs="0" maxOccurs="2">
  <xs:element name="el1" type="xs:string"

minOccurs="1"/>
<xs:element name="el2" type="xs:string" minOccurs="1"/>
</xs:choice>

The bug will be fixed in Saxon by doing this rewrite
automatically.

Discussion