Hi Karen Jonathon, I am glad you've got the essense of the idea and the layout is in fact quite good in putting the idea to
test. That shows you know the business. But, there are some bridging ideas that I have not mentioned and they are not very much expanded in the official demo implementation of jaxb, leaving so much to desire.
>
I have 2 packages, the items.exec - that have the annotations. And generated, that do not have annotations.
The main bridge one has to build is to convert a JAXBElement from one package (type) to another. Without such conversion, it would result in error you've mentioned. That is inevitable.
To do the conversion, there are at least two ways to do, all need coder to do the hard work and no easy support from the library.
[1] One is to use JAXBSource() and JAXBResult() together with Marshaller/Unmarshaller. However, I just make a quick check on the documentation to discover that JAXBSource() actually implicitly use marshal() method for the purpose. That makes early use of Xml annotations resulting in impracticality of this method in converting the object from package items.exec to generated. So this channel is unfortunately a no-go.
[2] The other channel I would think of is to use cloning and casting. But, unfortunately, it seems functionality in that area is till left empty. Figuratively, there is not implementation of some sort of deep-copy of object of one package to another to make the conversion. Hence, that makes the coder the only choice to do it the hard way. This is the demo of how it can be done. For complicated object modelling, it is, I confess, quite too much work to make it attractive.
The approach allows one to massage the concepts in a broad sense, whether it is practical, it is left to each one to evaluate.