/**
* convertComplexTypeDef
*/
private QName convertComplexTypeDef(XSComplexTypeDefinition ctDef, String namespace, String nameHint) throws SchemaConversionException {
NodeTypeDef ntd;
// Check if this ComplexTypeDef has already been converted
// if so, return the name of the corresponding NodeTypeDef
if (nodeTypeDefs.containsKey(ctDef)) {
ntd = (NodeTypeDef) nodeTypeDefs.get(ctDef);
return ntd.getName();
}
// Otherwise create a new NodeTypeDef and add it to the map
// keyed by the CTDef from which it was converted
NodeTypeDef ntDef = new NodeTypeDef();
nodeTypeDefs.put(ctDef, ntDef);
// Make name for the node type, inventing names for anonymous CTDefs
// and avoiding repetitions.
QName ntName;
if (ctDef.getAnonymous()) {
if (nameHint == null) {
throw new SchemaConversionException("Anonymous complex type definition encountered without name hint");
}
namespace = noNull(namespace);
QName baseName = new QName(namespace, nameHint + "Type");
Integer count = (Integer) nodeTypeBaseNames.get(baseName);
if (count == null) {
nodeTypeBaseNames.put(baseName, new Integer(0));
ntName = baseName;
} else {
int newCount = count.intValue() + 1;
ntName = new QName(namespace, nameHint + "Type_" + Integer.toString(newCount));
nodeTypeBaseNames.put(baseName, new Integer(newCount));
}
} else {
ntName = new QName(noNull(ctDef.getNamespace()), ctDef.getName());
}
// set the name of the node type
ntDef.setName(ntName);
// Fill in the rest of the node type def
buildNodeTypeDef(ntDef, ctDef);
return ntName;
}