Boolean abstractAtt = (Boolean) attrValues[XSAttributeChecker.ATTIDX_ABSTRACT];
XInt blockAtt = (XInt) attrValues[XSAttributeChecker.ATTIDX_BLOCK];
Boolean mixedAtt = (Boolean) attrValues[XSAttributeChecker.ATTIDX_MIXED];
XInt finalAtt = (XInt) attrValues[XSAttributeChecker.ATTIDX_FINAL];
XSComplexTypeDecl complexType = new XSComplexTypeDecl();
complexType.fName = complexTypeName;
complexType.fTargetNamespace = schemaDoc.fTargetNamespace;
complexType.fBlock = blockAtt == null ?
schemaDoc.fBlockDefault : blockAtt.shortValue();
complexType.fFinal = finalAtt == null ?
schemaDoc.fFinalDefault : finalAtt.shortValue();
if (abstractAtt != null && abstractAtt.booleanValue())
complexType.setIsAbstractType();
Element child = null;
try {
// ---------------------------------------------------------------
// First, handle any ANNOTATION declaration and get next child
// ---------------------------------------------------------------
child = DOMUtil.getFirstChildElement(complexTypeDecl);
if (child != null) {
// traverse annotation if any
if (DOMUtil.getLocalName(child).equals(SchemaSymbols.ELT_ANNOTATION)) {
traverseAnnotationDecl(child, attrValues, false, schemaDoc);
child = DOMUtil.getNextSiblingElement(child);
}
if (child !=null && DOMUtil.getLocalName(child).equals(SchemaSymbols.ELT_ANNOTATION)) {
throw new ComplexTypeRecoverableError("src-ct.0.1",
new Object[]{complexType.fName,SchemaSymbols.ELT_ANNOTATION},
child);
}
}
// ---------------------------------------------------------------
// Process the content of the complex type definition
// ---------------------------------------------------------------
if (child==null) {
//
// EMPTY complexType with complexContent
//
// set the base to the anyType
complexType.fBaseType = SchemaGrammar.fAnyType;
processComplexContent(child, complexType, mixedAtt.booleanValue(), false,
schemaDoc, grammar);
}
else if (DOMUtil.getLocalName(child).equals
(SchemaSymbols.ELT_SIMPLECONTENT)) {
//
// SIMPLE CONTENT
//
traverseSimpleContent(child, complexType, schemaDoc, grammar);
Element elemTmp = DOMUtil.getNextSiblingElement(child);
if (elemTmp != null) {
String siblingName = DOMUtil.getLocalName(elemTmp);
throw new ComplexTypeRecoverableError("src-ct.0.1",
new Object[]{complexType.fName,siblingName},
elemTmp);
}
}
else if (DOMUtil.getLocalName(child).equals
(SchemaSymbols.ELT_COMPLEXCONTENT)) {
traverseComplexContent(child, complexType, mixedAtt.booleanValue(),
schemaDoc, grammar);
Element elemTmp = DOMUtil.getNextSiblingElement(child);
if (elemTmp != null) {
String siblingName = DOMUtil.getLocalName(elemTmp);
throw new ComplexTypeRecoverableError("src-ct.0.1",
new Object[]{complexType.fName,siblingName},
elemTmp);
}
}
else {
//
// We must have ....
// GROUP, ALL, SEQUENCE or CHOICE, followed by optional attributes
// Note that it's possible that only attributes are specified.
//
// set the base to the anyType
complexType.fBaseType = SchemaGrammar.fAnyType;
processComplexContent(child, complexType, mixedAtt.booleanValue(), false,
schemaDoc, grammar);
}
}
catch (ComplexTypeRecoverableError e) {
handleComplexTypeError(e.getMessage(), e.errorSubstText,
complexType, e.errorElem);
}
if (DEBUG) {
System.out.println(complexType.toString());
}
return complexType;
}