// via XMLRootRecord.
if(clazz == ClassConstants.OBJECT) {
SAXUnmarshallerHandler saxUnmarshallerHandler = new SAXUnmarshallerHandler(xmlUnmarshaller.getXMLContext());
try {
XMLReader xmlReader = getXMLReader();
saxUnmarshallerHandler.setXMLReader(xmlReader);
saxUnmarshallerHandler.setUnmarshaller(xmlUnmarshaller);
saxUnmarshallerHandler.setKeepAsElementPolicy(UnmarshalKeepAsElementPolicy.KEEP_UNKNOWN_AS_ELEMENT);
setContentHandler(xmlReader, saxUnmarshallerHandler);
xmlReader.parse(systemId);
} catch (IOException e) {
throw XMLMarshalException.unmarshalException(e);
} catch (SAXException e) {
throw convertSAXException(e);
} finally {
xmlUnmarshaller.getStringBuffer().reset();
}
// resolve any mapping references
saxUnmarshallerHandler.resolveReferences();
return saxUnmarshallerHandler.getObject();
} else {
// for XMLObjectReferenceMappings we need a non-shared cache, so
// try and get a Unit Of Work from the XMLContext
try{
session = xmlUnmarshaller.getXMLContext().getReadSession(clazz);
xmlDescriptor = (XMLDescriptor) session.getDescriptor(clazz);
unmarshalRecord = (UnmarshalRecord) xmlDescriptor.getObjectBuilder().createRecord(session);
}catch(XMLMarshalException xme){
if(xme.getErrorCode() == XMLMarshalException.DESCRIPTOR_NOT_FOUND_IN_PROJECT){
isPrimitiveWrapper = isPrimitiveWrapper(clazz);
if (isPrimitiveWrapper) {
unmarshalRecord = new XMLRootRecord(clazz);
unmarshalRecord.setSession((AbstractSession) xmlUnmarshaller.getXMLContext().getSession(0));
}else{
throw xme;
}
}else{
throw xme;
}
}
}
try {
XMLReader xmlReader = getXMLReader();
unmarshalRecord.setXMLReader(xmlReader);
unmarshalRecord.setUnmarshaller(xmlUnmarshaller);
setContentHandler(xmlReader, unmarshalRecord);
xmlReader.setLexicalHandler(unmarshalRecord);
xmlReader.parse(systemId);
} catch (IOException e) {
throw XMLMarshalException.unmarshalException(e);
} catch (SAXException e) {
throw convertSAXException(e);
} finally {