I have a Teiid view model mapped from an XML schema and am running into an issue when I pull results out of the mapped Teiid XML document. I am utilizing JAX-B to marshal and unmarshal objects in my application. One of the objects that I created stores a list of a "base type" (kind of like a shopping cart.) The base type is defined in the XSD as "abstract" which carries over to the generated Java class. What I am doing is returning the objects from Teiid (the items in the cart) and adding them in the "cart" element XML. Doing this does not work from a JAX-B perspective because the element returned is the implementation class (i.e. CompactDisc or T-Shirt, etc...) and not the abstract base "item" class which is what is needed. This would force me to unmarshal each implementation object one-by-one returned from the Teiid call and then add it to the shopping cart Java object and marshal the shopping cart after adding all necessary items. The resulting XML that is created is in essence the same as what comes from Teiid with one major difference, the element is declared as the base item with an "xsi:type" declaring the implementation class (as defined in the XML spec.) The result looks something like "<item xsi:type="electronics:compactDisc" ...>".
O.k., so now for my question I can see where I am able to specify the XSD component after mapping a concrete/implementation type and it comes back as the base item, however, it does not include the very important "xsi:type" to identify its specific type. Is there a way to properly handle casting to a super type which would include this "xsi:type" tag?
I did see a JIRA relating to xsi:type, however, it indicated having a similar interface to "choice" which I don't think is necessary in this scenario since we already know the specific type we are just simply returning a super type and need it to follow the XML spec which would be to include the xsi:type tag.
Thanks for your time any guidance would be greatly appreciated. Take care.