Hi there,

Let me first state that, wow, xmlbeans really rocks. I'm loving it. Well done again Apache community.

I have two sets of schemas - each set relating to the separate generation of xmlbean classes representing the xsds.

Both sets of generated classes are on my classpath.

In one set, I generate all of the classes required for the GML set of schemas.

The other set comprises just one xsd that extends the GML schemas.

In the context of the GML schemas, I can use substitution groups just fine e.g.

 AbstractTimeSliceType abstractTimeSliceType = historyPropertyType
  .addNewAbstractTimeSlice();
MovingObjectStatusType movingObjectStatusType = (MovingObjectStatusType) abstractTimeSliceType
  .substitute(new QName(
  "http://www.opengis.net/gml/3.2";,
  "MovingObjectStatus"),
  MovingObjectStatusType.type);

and I get the correct substitution.

However if I try and substitute something from my other schema (the extensions to GML) e.g. if I use my own extension of MovingObjectStatusType:

JourneyStatusType journeyStatusType = (JourneyStatusType) movingObjectStatusType
  .substitute(
  new QName(
   "http://www.classactionpl.com/gml/journeyFeatures/2.0";,
   "JourneyStatus"),
  JourneyStatusType.type);

then I get a ClassCastException i.e. the substitution isn't returning the JourneyStatusType.

From the doco, in order for the operation to succeed, several conditions must hold:

* the container of this type must be an element = TRUE

* a global element with the name newName must exist and must be in the substition group of the containing element = TRUE i.e.:

 <element
  name="JourneyStatus"
  type="journeyFeatures:JourneyStatusType"
  substitutionGroup="gml:MovingObjectStatus"/>

* the newType type must be consistent with the declared type of the new element = TRUE i.e.:

 <complexType name="JourneyStatusType">
  <complexContent>
   <extension base="gml:MovingObjectStatusType">
...
  </complexContent>
 </complexType>

Is there a known limitation/issue with substituting an element in the way I'm trying to i.e. substituting from a separate namespace?

Cheers,
-C

P.S. I'm also happy if someone spots a mistake in what I'm doing above!

Reply via email to