for (int i = 0; i < tops.size(); i++) {
ElementBase top = (ElementBase)tops.get(i);
if (top.type() == ElementBase.MAPPING_ELEMENT) {
// find or create schema for mapped class
MappingElementBase mapping = (MappingElementBase)top;
String uri = mapping.getNamespace().getUri();
Element schema = (Element)m_schemaMap.get(uri);
if (schema == null) {
// build new schema element for this namespace
schema = m_document.createElementNS(XSD_URI, "schema");
m_schemaMap.put(uri, schema);
// set qualification attributes if needed
if (m_isElementQualified) {
schema.setAttribute("elementFormDefault", "qualified");
}
if (m_isAttributeQualified) {
schema.setAttribute("attributeFormDefault",
"qualified");
}
// add namespace declarations to element
if (uri == null) {
schema.setPrefix("xsd");
} else {
schema.setAttribute("targetNamespace", uri);
schema.setAttributeNS(XMLNS_URI, "xmlns:tns", uri);
schema.setAttributeNS(XMLNS_URI, "xmlns", XSD_URI);
}
schema.setAttributeNS(XMLNS_URI, "xmlns:xsd", XSD_URI);
// add spacing for first child node
indentForClose(schema);
}
// add spacer and comment before actual definition
indentForClose(schema);
String cname = mapping.getClassName();
addComment(schema, " Created from mapping for class " +
cname + " ");
if (mapping.isAbstract()) {
// add mapping as global type in binding
Element type = defineNestedStructure(mapping, schema);
type.setAttribute("name", simpleClassName(cname));
} else {
// add mapping as global element in binding
Element element = addChildElement(schema, "element");
element.setAttribute("name", mapping.getName());
// check type of mapping definition
if (mapping.getMarshaller() != null ||
mapping.getUnmarshaller() != null) {
// use "any" for custom marshaller/unmarshaller
Element type = addChildElement(element, "complexType");
Element seq = addChildElement(type, "sequence");
addComment(seq, " Replace \"any\" with details of " +