users@jaxb.java.net

complexType extension and all - is this legal?

From: Dmitri Colebatch <dim_at_colebatch.com>
Date: Mon, 13 Aug 2007 22:12:32 +1000

Hi all,

I've been silently enjoying JAXB2 for a couple of years now and should
start with a word of thanks for the work of Kohsuke and the others who
have got JAXB2 to where it is today.

Onto my problem at hand, I'm not sure if what I'm trying to do is
valid xml schema or if its just that xjc (or the sax parser) cant
handle it. I'm trying to create a schema that uses extension of a
complexType that uses all instead of sequence. My schema looks like
this:

<xsd:schema targetNamespace="urn:dim.colebatch.com:test"
           xmlns:tns="urn:dim.colebatch.com:test"
           xmlns:xsd="http://www.w3.org/2001/XMLSchema"
           elementFormDefault="qualified"
attributeFormDefault="unqualified" version="1">

   <xsd:complexType name="ParentType" abstract="true">
               <xsd:all>
           <xsd:element name="Foo" type="xsd:string" minOccurs="1"
maxOccurs="1" />
           <xsd:element name="Bar" type="xsd:string" minOccurs="1"
maxOccurs="1"/>
       </xsd:all>
       </xsd:complexType>

   <xsd:element name="ElementWithAnonymousChildType">
               <xsd:complexType>
                       <xsd:complexContent>
                               <xsd:extension base="tns:ParentType">
                                       <xsd:all>
                       <xsd:element name="X" type="xsd:int"
minOccurs="1" maxOccurs="1"/>
                       <xsd:element name="Y" type="xsd:int"
minOccurs="1" maxOccurs="1"/>
                   </xsd:all>
                               </xsd:extension>
                       </xsd:complexContent>
               </xsd:complexType>
       </xsd:element>

</xsd:schema>

And when running xjc (2.1.4-b02-fcs), it fails:

parsing a schema...
[ERROR] An internal error occurred while formatting the following message:
 cos-all-limited.1.2: An 'all' model group must appear in a particle
with {min occurs} = {max occurs} = 1, and that particle must be part
of a pair which constitutes the {content type} of a complex type
definition.
 line 17 of file:/C:/tmp/jaxb-all-extension/test.xsd

Failed to parse a schema.

Line 17 is the xsd:all under the extension of the ParentType. XMLSpy
thinks this is valid, my reading of the spec suggests its valid, so
I'm suspecting this is a bug somewhere.

Does anyone have any suggestions?

cheers,
dim