Element keyElement = new Element();
keyElement.setName(Property.DEFAULT_KEY_NAME);
keyElement.setMinOccurs(Occurs.ZERO);
JavaClass keyType = property.getKeyType();
JavaClass valueType = property.getValueType();
if (keyType == null) {
keyType = helper.getJavaClass(Object.class);
}
if (valueType == null) {
valueType = helper.getJavaClass(Object.class);
}
String typeName;
QName keySchemaType = getSchemaTypeFor(keyType);
if (keySchemaType != null) {
TypeInfo targetInfo = this.typeInfo.get(keyType.getQualifiedName());
if (targetInfo != null) {
Schema keyElementSchema = this.getSchemaForNamespace(keySchemaType.getNamespaceURI());
//add an import here
addImportIfRequired(schema, keyElementSchema, keySchemaType.getNamespaceURI());
}
String prefix;
if (keySchemaType.getNamespaceURI().equals(javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI)) {
prefix = Constants.SCHEMA_PREFIX;
} else {
prefix = getPrefixForNamespace(schema, keySchemaType.getNamespaceURI());
}
if (prefix != null && !prefix.equals(EMPTY_STRING)) {
typeName = prefix + COLON + keySchemaType.getLocalPart();
} else {
typeName = keySchemaType.getLocalPart();
}
keyElement.setType(typeName);
}
entrySequence.addElement(keyElement);
Element valueElement = new Element();
valueElement.setName(Property.DEFAULT_VALUE_NAME);
valueElement.setMinOccurs(Occurs.ZERO);
QName valueSchemaType = getSchemaTypeFor(valueType);
if (valueSchemaType != null) {
TypeInfo targetInfo = this.typeInfo.get(valueType.getQualifiedName());
if (targetInfo != null) {
Schema valueElementSchema = this.getSchemaForNamespace(valueSchemaType.getNamespaceURI());
//add an import here
addImportIfRequired(schema, valueElementSchema, valueSchemaType.getNamespaceURI());
}
String prefix;
if (valueSchemaType.getNamespaceURI().equals(javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI)) {
prefix = Constants.SCHEMA_PREFIX;
} else {
prefix = getPrefixForNamespace(schema, valueSchemaType.getNamespaceURI());
}
if (prefix != null && !prefix.equals(EMPTY_STRING)) {
typeName = prefix + COLON + valueSchemaType.getLocalPart();
} else {
typeName = valueSchemaType.getLocalPart();
}
valueElement.setType(typeName);
}
entrySequence.addElement(valueElement);
entryComplexType.setSequence(entrySequence);
JavaClass descriptorClass = helper.getJavaClass(typeInfo.getDescriptor().getJavaClassName());
JavaClass mapValueClass = helper.getJavaClass(MapValue.class);
if (mapValueClass.isAssignableFrom(descriptorClass)) {
element.setComplexType(entryComplexType);
element.setMaxOccurs(Occurs.UNBOUNDED);
} else {
ComplexType complexType = new ComplexType();
Sequence sequence = new Sequence();