users@jaxb.java.net

substitutionGroup over multiple files

From: Andreas Pakulat <pakulat_at_rostock.zgdv.de>
Date: Wed, 05 Apr 2006 16:28:47 +0200

Hi,

I've got a serious problem here, which I guess is related to the
schema's using substitutionGroup.

I have schema file a.xsd, defining an abstract type and an abstract
element for that type. In the same file there are a number of extensions
of this abstract type together with elements using the types like this:

<xs:complexType name="mytype">
   <xs:complexContent>
     <xs:extension base="smXML:_myabstractType">
       ...
     </xs:extension>
   </xs:complexContent<
</xs:comlexType>
<xs:element name="myelem" type="smXML:mytype"
substitutionGroup="smXML:_myabstractelem" />

That is working fine, however having a 2nd xml schema "b.xsd", which
imports the first one and defines a type like this:

<xs:complexType name="mysecondType">
   <xs:complexContent>
     <xs:extension base="smXML:_myabstractType">
       ...
     </xs:extension>
   </xs:complexContent<
</xs:comlexType>
<xs:element name="mysecondelem" type="mysecondType"
substitutionGroup="smXML:_myabstractelem"/>

Now when I try to unmarshal an XML document that validates against this
schema, Jaxb always tells me that:

unexpected element (uri:"http://myns", local:"mysecondType"). Expected
elements are
<{http://metadata.dgiwg.org/smXML}_myabstractType>,<{http://metadata.dgiwg.org/smXML}mytype>at-1-1

The only difference I can see is the targetNamespace of both schemas.
While a.xsd uses targetNamespace="aaa" xmlns:smXML="aaa", b.xsd uses
targetNamespace="bbb" xmlns="bbb". Could this be the cause of the problem?

If not, what else could cause this?

Oh, btw: I feed xjc with a schema file that imports b.xsd (which in turn
imports a.xsd).

Andreas