try {
MessageElement me = context.getCurElement();
XmlOptions opts = new XmlOptions()
.setLoadReplaceDocumentElement(null);
XmlObject xObj = XmlObject.Factory.parse(me, opts);
SchemaType jt = (SchemaType) mJavaType.getField("type").get(null);
XmlObject converted = xObj.changeType(jt);
if (converted != null) {
setValue(converted);
} else {
XmlObject[] children = xObj.selectChildren(QNameSet.ALL);
for (int j = 0; j < children.length; j++) {
converted = xObj.changeType(jt);
if (converted != null) {
setValue(converted);
break;
}
}
}
} catch (Exception xe) {
throw new SAXException(xe);
}