this.xmlType.setParentType(parentType.getXmlType());
// import the complex type namespace if needed.
if (!xmlSchema.containsNamespace(this.xmlType.getParentType().getQname().getNamespaceURI())){
// if the element namespace does not exists we have to add it
if (!this.xmlType.getParentType().getQname().getNamespaceURI().equals(Constants.URI_2001_SCHEMA_XSD)) {
XmlImport xmlImport = new XmlImport(this.xmlType.getParentType().getQname().getNamespaceURI());
xmlSchema.addImport(xmlImport);
}
xmlSchema.addNamespace(this.xmlType.getParentType().getQname().getNamespaceURI());
}
}
// add elements of the elementFields
ElementField elementField;
for (Iterator iter = this.elementFields.iterator();iter.hasNext();){
elementField = (ElementField) iter.next();
if (!elementField.isSchemaGenerated()){
// if it is not already processed process it.
elementField.generateSchema(configurator,schemaMap);
}
this.xmlType.addElement(elementField.getElement());
// we have to set the namespaces of these element complex types properly
QName elementTypeQName = elementField.getElement().getType().getQname();
if (!xmlSchema.containsNamespace(elementTypeQName.getNamespaceURI())){
// if the element namespace does not exists we have to add it
if (!elementTypeQName.getNamespaceURI().equals(Constants.URI_2001_SCHEMA_XSD)) {
XmlImport xmlImport = new XmlImport(elementTypeQName.getNamespaceURI());
xmlSchema.addImport(xmlImport);
}
xmlSchema.addNamespace(elementTypeQName.getNamespaceURI());
}
}
//add attribute fields
AttributeField attributeField;
for (Iterator iter = this.attributeFields.iterator(); iter.hasNext();){
attributeField = (AttributeField) iter.next();
if (!attributeField.isSchemaGenerated()){
// if it is not already processed process it.
attributeField.generateSchema(configurator,schemaMap);
}
this.xmlType.addAttribute(attributeField.getAttribute());
// we have to set the namespaces of these element complex types properly
QName attributeTypeQName = attributeField.getAttribute().getType().getQname();
if (!xmlSchema.containsNamespace(attributeTypeQName.getNamespaceURI())){
// if the element namespace does not exists we have to add it
if (!attributeTypeQName.getNamespaceURI().equals(Constants.URI_2001_SCHEMA_XSD)) {
XmlImport xmlImport = new XmlImport(attributeTypeQName.getNamespaceURI());
xmlSchema.addImport(xmlImport);
}
xmlSchema.addNamespace(attributeTypeQName.getNamespaceURI());
}