You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by MATTHEW AMOS <ma...@bbva.com> on 2012/11/02 15:14:22 UTC

Question about restriction of sequences

I am restricting a group containing a sequence of elements to a group
containing a sequence with no elements. I am experiencing different
behaviour dependant on the number of elements in the base sequence. If
there is more than one element in the base sequence then there is no
problem. If there is exactly one element I experience a
cos-particle-restrict.2 validation error "Forbidden particle restriction:
'seq:elt'".

Looking at the source code for org.apache.xerces.impl.xs.XSConstraints this
message is experienced if the derived type is a sequence and the base type
is an element. I cannot see why this code would be executed, both the base
and derived types are sequences. It is as though the sequence of one
element is treated as though it were an element.

I am struggling to see if this is a bug in Xerces, or a quirk of the XML
Schema specification.

Does the specification explicitly state that a sequence of one element is
treated as an element?

The table of valid restrictions for the valid particle restrictions states
that the "Recurse" algorithm should be invoked if both particles are a
sequence. I can't see how, but is that rule responsible for the difference
in treatment of the two cases?

The behaviour seems inconsistent to me. If a sequence of n>1 elements can
be restricted to a sequence of 0 elements, why would a sequence of 1
element not be?

I attach two schema files that illustrate the issue. The group
"SingleElement", when restricted, experiences the validation error. The
group "TwoElements", when restricted, does not.

A work around is to first extend the group to add another element to the
sequence, and then to restrict it afterwards, but this feels wrong.

MAtt