BeanTypeInfo inf = getTypeInfo();
Element complex = new Element("complexType", SOAPConstants.XSD_PREFIX, SOAPConstants.XSD);
complex.setAttribute(new Attribute("name", getSchemaType().getLocalPart()));
root.addContent(complex);
Type sooperType = getSuperType();
/*
* See Java Virtual Machine specification:
* http://java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html#75734
*/
if (((inf.getTypeClass().getModifiers() & Modifier.ABSTRACT) != 0)
&& !inf.getTypeClass().isInterface()) {
complex.setAttribute(new Attribute("abstract", "true"));
}
if (inf.isExtension() && sooperType != null) {
Element complexContent = new Element("complexContent",
SOAPConstants.XSD_PREFIX,
SOAPConstants.XSD);
complex.addContent(complexContent);
complex = complexContent;
}
/*
* Decide if we're going to extend another type. If we are going to
* defer, then make sure that we extend the type for our superclass.
*/
boolean isExtension = inf.isExtension();
Element dummy = complex;
if (isExtension && sooperType != null) {
Element extension = new Element("extension", SOAPConstants.XSD_PREFIX, SOAPConstants.XSD);
complex.addContent(extension);
QName baseType = sooperType.getSchemaType();
extension.setAttribute(new Attribute("base", getNameWithPrefix2(root, baseType
.getNamespaceURI(), baseType.getLocalPart())));
dummy = extension;
}
Element seq = null;
boolean needXmime = false;
boolean needUtilityTypes = false;
// Write out schema for elements
for (Iterator itr = inf.getElements(); itr.hasNext();) {
QName name = (QName)itr.next();
if (isExtension) {
PropertyDescriptor pd = inf.getPropertyDescriptorFromMappedName(name);
assert pd.getReadMethod() != null && pd.getWriteMethod() != null;
if (pd.getReadMethod().getDeclaringClass() != inf.getTypeClass()) {
continue;
}
}
if (seq == null) {
seq = new Element("sequence", SOAPConstants.XSD_PREFIX, SOAPConstants.XSD);
dummy.addContent(seq);
}
Element element = new Element("element", SOAPConstants.XSD_PREFIX, SOAPConstants.XSD);
seq.addContent(element);
Type type = getType(inf, name);
String nameNS = name.getNamespaceURI();
String nameWithPrefix = getNameWithPrefix(root, nameNS, name.getLocalPart());
String prefix = NamespaceHelper.getUniquePrefix(root, type.getSchemaType().getNamespaceURI());
writeTypeReference(name, nameWithPrefix, element, type, prefix, root);
needXmime |= type.usesXmime();
needUtilityTypes |= type.usesUtilityTypes();
}
if (needXmime) {
addXmimeToSchema(root);
}
if (needUtilityTypes) {
AegisContext.addUtilityTypesToSchema(root);
}
/**
* if future proof then add <xsd:any/> element
*/
if (inf.isExtensibleElements()) {
if (seq == null) {
seq = new Element("sequence", SOAPConstants.XSD_PREFIX, SOAPConstants.XSD);
dummy.addContent(seq);
}
seq.addContent(createAnyElement());
}
// Write out schema for attributes
for (Iterator itr = inf.getAttributes(); itr.hasNext();) {
QName name = (QName)itr.next();
Element element = new Element("attribute", SOAPConstants.XSD_PREFIX, SOAPConstants.XSD);
dummy.addContent(element);
Type type = getType(inf, name);
String nameNS = name.getNamespaceURI();
String nameWithPrefix = getNameWithPrefix(root, nameNS, name.getLocalPart());
String prefix = NamespaceHelper.getUniquePrefix(root, type.getSchemaType().getNamespaceURI());
element.setAttribute(new Attribute("name", nameWithPrefix));
element.setAttribute(TypeUtil.createTypeAttribute(prefix, type, root));
}
/**