if (null == typeName && !readToDocument) {
throw new DatabindingException("Missing 'xsi:type' attribute value");
}
Type type = null;
QName typeQName = null;
if (typeName != null) {
typeQName = extractQName(reader, typeName);
} else {
typeQName = reader.getName();
}
TypeMapping tm = context.getTypeMapping();
if (tm == null) {
tm = getTypeMapping();
}
type = tm.getType(typeQName);
if (type == null) {
type = tm.getType(getSchemaType());
}
if (type == this) {
throw new DatabindingException("Could not determine how to read type: " + typeQName);
}
if (type == null && readToDocument) {
type = getTypeMapping().getType(Document.class);
}
if (null == type) {
// TODO should check namespace as well..
if (serializedWhenUnknown && "serializedJavaObject".equals(typeName)) {
return reconstituteJavaObject(reader);
}
throw new DatabindingException("No mapped type for '" + typeName + "' (" + typeQName + ")");
}
return type.readObject(reader, context);
}