Hi , instance gets always super type

Hi,
 
I have a problem using xmlbeans with inherited types with java. In my 
commons.xsd there is a complex type Operation and some other types which are 
extending Operation. In a MoreSpecifix.xsd is commons.xsd imported and a 
complex type Config is declared. This type Config does declare a sequence of 
Operation. So it should be possible to add all types which extend Operation to 
the sequence in Config.
 
After the generation of the java classes I run into the following problems:
 
First try:
final ConfigDocument configDocument = ConfigDocument.Factory.newInstance();
final Config newConfig = configDocument.addNewConfig();

final Operation[] ops = new OperationType[1];

ops[0] = createConcreteOperationDummy();

newConfig.setOperationArray(ops);

With the last line my concrete operation instance gets the type from the super 
class Operation and I can no more access the extended fields.

Second try:

final ConfigDocument configDocument = ConfigDocument.Factory.newInstance();

final Config newConfig = configDocument.addNewConfig();

final Operation newOperation = newConfig.addNewOperation();

final ConcreteOperation concreteOp = (ConcreteOperation) 
newOperation.changeType(ConcreteOperation.type);

On the last line I get a ClassCastException. 

Has someone an idea what is wrong ? Probably the xsd definitions (made with 
XMLSpy) ?

Regards,

Oliver


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@xmlbeans.apache.org
For additional commands, e-mail: user-h...@xmlbeans.apache.org

Reply via email to