Thank you Sandy. I feel a bit stupid now. Re-reading this section after your reply, the definition of pointlessness now seems obvious. :0)
FYI I am attempting to restrict a large schema provided by another organisation down to a more manageable subset. They specified it using XML Schema 2001 so in the short term modifying the base type is not going to be an option. MAtt On 2 November 2012 15:51, Sandy Gao <[email protected]> wrote: > Matt, > > The spec is your friend (well, or maybe the enemy in your case). > > > > Does the specification explicitly state that a sequence of one element > is treated as an element? > > Exactly. See clause 2.2.2.2.1 in [1]. > > You can work around it by adding an empty sequence to the base: > > <xs:group name="SingleElement"> > <xs:sequence> > <xs:element name="A" type="xs:string" minOccurs="0" > maxOccurs="unbounded"/> > <xs:sequence/> > </xs:sequence> > </xs:group> > > Or you can look at XML Schema 1.1 [2], where particle restriction rules > have been significantly improved. It allows many "obviously valid > restrictions" that were forbidden by 1.0. > > [1] http://www.w3.org/TR/xmlschema-1/#cos-particle-restrict > [2] http://www.w3.org/TR/xmlschema11-1/#sec-cos-content-act-restrict > > Thanks, > Sandy Gao > IBM Canada > (1-905) 413-3255 T/L 313-3255* > **[email protected]* <[email protected]> > > [image: Inactive hide details for MATTHEW AMOS ---11/02/2012 10:22:35 > AM---I am restricting a group containing a sequence of elements t]MATTHEW > AMOS ---11/02/2012 10:22:35 AM---I am restricting a group containing a > sequence of elements to a group containing a sequence with no > > From: MATTHEW AMOS <[email protected]> > To: [email protected], > Date: 11/02/2012 10:22 AM > Subject: 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 > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > > #### base.xsd has been removed from this note on November 02 2012 by Sandy > Gao > #### restrict.xsd has been removed from this note on November 02 2012 by > Sandy Gao > >
<<graycol.gif>>
