You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Christopher Hunt <hu...@internode.on.net> on 2008/06/04 14:12:08 UTC

Substitution Group issue when trying to substitute a new namespace?

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!

RE: Substitution Group issue when trying to substitute a new namespace?

Posted by Radu Preotiuc-Pietro <ra...@bea.com>.
Unfortunately, there is a known limitation: both the head element and
the substitution have to be in the same jar file (i.e. compiled at the
same time). See http://issues.apache.org/jira/browse/XMLBEANS-299
 
Radu


________________________________

	From: Christopher Hunt [mailto:huntc@internode.on.net] 
	Sent: Wednesday, June 04, 2008 5:12 AM
	To: user@xmlbeans.apache.org
	Subject: Substitution Group issue when trying to substitute a
new namespace?
	
	
	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!


Notice:  This email message, together with any attachments, may contain information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated entities,  that may be confidential,  proprietary,  copyrighted  and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it.