Is it possible to use JAXB to unmarshall xml to a specific Java class based on an attribute of the xml?
AFAIK, you'll have to write an XmlAdapter which knows how to handle the marshal/unmarshalling of the Shape.