StringBuilder buf = new StringBuilder();
//Handle Complex Type
if (xstype instanceof XSComplexTypeDefinition)
{
XSComplexTypeDefinition jxstype = (XSComplexTypeDefinition)xstype;
String jxsTypeName = jxstype.getName();
boolean isSimple = jxstype.getContentType() == XSComplexTypeDefinition.CONTENTTYPE_SIMPLE;
if (xstype.getAnonymous())
buf.append("<complexType>");
else buf.append("<complexType name='" + jxsTypeName + "'>");
XSTypeDefinition xsbase = (XSTypeDefinition)jxstype.getBaseType();
String baseType = null;
if (xsbase != null && !("anyType".equals(xsbase.getName())))
baseType = getPrefix(xsbase.getNamespace()) + ":" + xsbase.getName();
if (baseType != null)
{
buf.append((isSimple) ? "<simpleContent>" : "<complexContent>");
buf.append("<extension base='" + baseType + "'>");
}
XSParticle xsp = jxstype.getParticle();
if (xsp != null)
appendComplexTypeDefinition(buf, jxstype);
XSObjectList list = jxstype.getAttributeUses();
for (int i = 0; i < list.getLength(); i++)
{
XSAttributeUse use = (XSAttributeUse)list.item(i);
XSAttributeDeclaration decl = use.getAttrDeclaration();
buf.append(write(decl));