List<SchemaElementComplex> complexElements = new ArrayList<SchemaElementComplex>();
Short optionalSimplyType = null;
String optionalSimplyTypeName = null;
if (complexActualElement.getSimpleType() != null) {
XSSimpleTypeDecl simpleType = (XSSimpleTypeDecl) complexActualElement.getSimpleType();
optionalSimplyType = simpleType.getPrimitiveKind();
optionalSimplyTypeName = simpleType.getName();
}
SchemaElementComplex complexElement = new SchemaElementComplex(complexElementName, complexElementNamespace, attributes, complexElements, simpleElements, isArray, optionalSimplyType, optionalSimplyTypeName);
// add attributes
XSObjectList attrs = complexActualElement.getAttributeUses();
for(int i = 0; i < attrs.getLength(); i++)
{
XSAttributeUse attr = (XSAttributeUse)attrs.item(i);
String namespace = attr.getAttrDeclaration().getNamespace();
String name = attr.getAttrDeclaration().getName();
XSSimpleTypeDecl simpleType = (XSSimpleTypeDecl) attr.getAttrDeclaration().getTypeDefinition();
attributes.add(new SchemaItemAttribute(namespace, name, simpleType.getPrimitiveKind(), simpleType.getName()));
}
if ((complexActualElement.getContentType() == XSComplexTypeDefinition.CONTENTTYPE_ELEMENT) ||
(complexActualElement.getContentType() == XSComplexTypeDefinition.CONTENTTYPE_MIXED))
{
// has children
XSParticle particle = complexActualElement.getParticle();
if (particle.getTerm() instanceof XSModelGroup )
{
XSModelGroup group = (XSModelGroup)particle.getTerm();
XSObjectList particles = group.getParticles();
for (int i = 0; i < particles.getLength(); i++)
{
XSParticle childParticle = (XSParticle)particles.item(i);
if (childParticle.getTerm() instanceof XSElementDeclaration)
{
XSElementDeclaration decl = (XSElementDeclaration) childParticle.getTerm();
boolean isArrayFlag = isArray(childParticle);
if (isSimpleTypeCategory(decl.getTypeDefinition().getTypeCategory())) {
XSSimpleTypeDecl simpleType = (XSSimpleTypeDecl) decl.getTypeDefinition();
Integer fractionDigits = getFractionRestriction(simpleType);
simpleElements.add(new SchemaElementSimple(decl.getName(), decl.getNamespace(), simpleType.getPrimitiveKind(), simpleType.getName(), isArrayFlag, fractionDigits));
}
if (isComplexTypeCategory(decl.getTypeDefinition().getTypeCategory()))
{
String name = decl.getName();