Bug #2388

<xs:choice/> accepts empty content as valid

Added by Michael Kay about 5 years ago. Updated over 4 years ago.

Schema conformance
Start date:
Due date:
% Done:


Estimated time:
Legacy ID:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:


An empty choice xs:choice/ should reject all possible content (the content must match at least one branch of the choice, and if there are no branches, it cannot do so). But Saxon appears to accept an empty element as a valid instance of the empty choice xs:choice/.


#1 Updated by Michael Kay about 5 years ago

  • Status changed from New to In Progress

I traced this to a problem in the spec, in the definition of "emptiable". The spec leads to the conclusion that xs:choice/ is emptiable (that is, an empty sequence is a valid instance), but it is not. Saxon uses the fact that the content is emptiable to conclude in this case that the only legal content is an empty sequence; it then optimizes away the element-only content model and the finite state machine by setting variety="EMPTY". I've patched it by refining this test so that we don't set variety=EMPTY when the content model is an empty choice. The patch fixes this case, though we need to check for side-effects.

#2 Updated by Michael Kay about 5 years ago

  • Status changed from In Progress to Resolved

The change appears to cause no problems with the test suite.

#3 Updated by O'Neil Delpratt about 5 years ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in version set to

Bug fix applied in the Saxon maintenance release.

#4 Updated by O'Neil Delpratt over 4 years ago

  • Sprint/Milestone set to
  • Applies to branch 9.6 added
  • Fix Committed on Branch 9.6 added
  • Fixed in Maintenance Release added

Please register to edit this issue

Also available in: Atom PDF