targetNamespacePrefixMap.put(targetNameSpace, targetNamespacePrefix);
}
XmlSchemaComplexType complexType = new XmlSchemaComplexType(xmlSchema);
XmlSchemaSequence sequence = new XmlSchemaSequence();
XmlSchemaComplexContentExtension complexExtension =
new XmlSchemaComplexContentExtension();
XmlSchemaElement eltOuter = new XmlSchemaElement();
schemaTypeName = new QName(targetNameSpace, simpleName, targetNamespacePrefix);
eltOuter.setName(simpleName);
eltOuter.setQName(schemaTypeName);
JClass sup = javaType.getSuperclass();
if ((sup != null) && !("java.lang.Object".compareTo(sup.getQualifiedName()) == 0) &&
!("org.apache.axis2".compareTo(sup.getContainingPackage().getQualifiedName()) == 0)
&&!("java.util".compareTo(sup.getContainingPackage().getQualifiedName()) == 0)) {
String superClassName = sup.getQualifiedName();
String superclassname = getSimpleName(sup);
String tgtNamespace;
String tgtNamespacepfx;
QName qName = typeTable.getSimpleSchemaTypeName(superClassName);
if (qName != null) {
tgtNamespace = qName.getNamespaceURI();
tgtNamespacepfx = qName.getPrefix();
} else {
tgtNamespace =
resolveSchemaNamespace(sup.getContainingPackage().getQualifiedName());
tgtNamespacepfx = (String) targetNamespacePrefixMap.get(tgtNamespace);
QName superClassQname = generateSchema(sup);
if(superClassQname!=null){
tgtNamespacepfx = superClassQname.getPrefix();
tgtNamespace = superClassQname.getNamespaceURI();
}
}
if (tgtNamespacepfx == null) {
tgtNamespacepfx = generatePrefix();
targetNamespacePrefixMap.put(tgtNamespace, tgtNamespacepfx);
}
//if the parent class package name is differ from the child
if (!((NamespaceMap) xmlSchema.getNamespaceContext()).values().
contains(tgtNamespace)) {
XmlSchemaImport importElement = new XmlSchemaImport();
importElement.setNamespace(tgtNamespace);
xmlSchema.getItems().add(importElement);
((NamespaceMap) xmlSchema.getNamespaceContext()).
put(generatePrefix(),tgtNamespace);
}
QName basetype = new QName(tgtNamespace, superclassname, tgtNamespacepfx);
complexExtension.setBaseTypeName(basetype);
complexExtension.setParticle(sequence);
XmlSchemaComplexContent contentModel = new XmlSchemaComplexContent();
contentModel.setContent(complexExtension);