uctx.setDocument(baos, null, "UTF-8", false);
T obj = type.cast(uctx.unmarshalElement());
// Find out version
XMLInputFactory factory = XMLInputFactory.newInstance();
baos.reset();
XMLStreamReader reader = factory.createXMLStreamReader(baos);
Version version = Version.UNKNOWN;
while (reader.hasNext())
{
int next = reader.next();