Hello,

I'm currently using XMLBeans 1.0.4 to parse a rather complex schema with
lots of abstract types, type-inheritance and use of substitution-groups.
After the parsing process all XmlObject instances are then tranformed
into POJOs for serialization reasons.
Because of a complex type-hierarchy the transformation code has a lot
of code like this:

 if (Y.type.isAssignableFrom(x.schemaType())) {
   Y y = (Y)x.changeType(Y.type)
   ...
 } else if (Z.type.isAssignableFrom(x.schemaType())) {
   Z z = (Z)x.changeType(Z.type)
   ...
 } else if { ...

Why is changeType() necessary at all? If I print the class of 'x' in
the example above, I get 'ZImpl' in the second case.
So when XMLBeans already creates the right class instance *before*
calling changeType(), where is the difference between

 Z z = (Z)x.changeType(T.type);

and a simple

 if (x instanceof Z) {
   Z z = (Z)x;
   ...
 }

I don't understand the javadoc comment on changeType() so well,
especially this part:
 "..., but there are no constraints at the roottype changes are never
  prohibited at the root of an xml tree."

What does this mean? Under which circumstances can I rely on using a direct cast delivering the same result as a call to changeType()?

Thanks in advance,

Robin.


PS: I will use XMLBeans 2.0 soon (substitution-groups!), so any answer
    based on 2.0 would be equally appreciated!


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to