this.elementDecl = elementDecl;
}
private void init()
{
DocumentBinding doc = ns.getDocument();
// first try to use XSD type
XSTypeDefinition typeDef = elementDecl.getTypeDefinition();
String typeBasedClsName = null;
if("http://www.w3.org/2001/XMLSchema".equals(typeDef.getNamespace()))
{
javaType = SimpleTypeBindings.classForType(typeDef.getName());
}
else if(typeDef.getName() != null)
{
NamespaceBinding ns = doc.getNamespace(typeDef.getNamespace());
typeBasedClsName = ns.getJavaPackage() + "." + Util.xmlNameToClassName(typeDef.getName(), true);
try
{
javaType = Thread.currentThread().getContextClassLoader().loadClass(typeBasedClsName);
}
catch(ClassNotFoundException e)
{
}
}
if(javaType == null)
{
// using type didn't help, let's try element's name
// note: here we use element's namespace, not type's one
NamespaceBinding ns = doc.getNamespace(elementDecl.getNamespace());
String elBasedClsName = ns.getJavaPackage() + "." + Util.xmlNameToClassName(elementDecl.getName(), true);
try
{
javaType = Thread.currentThread().getContextClassLoader().loadClass(elBasedClsName);
}