if (childName.equals(SchemaSymbols.ELT_ELEMENT)) {
if (mixedContent || elementContent) {
if ( DEBUGGING )
System.out.println(" child element name " + child.getAttribute(SchemaSymbols.ATT_NAME));
QName eltQName = traverseElementDecl(child);
index = fSchemaGrammar.addContentSpecNode( XMLContentSpec.CONTENTSPECNODE_LEAF,
eltQName.localpart,
eltQName.uri,
false);
seeParticle = true;
seeOtherParticle = true;
}
else {
reportSchemaError(SchemaMessageProvider.EltRefOnlyInMixedElemOnly, null);
}
}
else if (childName.equals(SchemaSymbols.ELT_GROUP)) {
index = traverseGroupDecl(child);
if (index == -1)
continue;
seeParticle = true;
seeOtherParticle = true;
}
else if (childName.equals(SchemaSymbols.ELT_ALL)) {
index = traverseAll(child);
seeParticle = true;
seeAll = true;
}
else if (childName.equals(SchemaSymbols.ELT_CHOICE)) {
index = traverseChoice(child);
seeParticle = true;
seeOtherParticle = true;
}
else if (childName.equals(SchemaSymbols.ELT_SEQUENCE)) {
index = traverseSequence(child);
seeParticle = true;
seeOtherParticle = true;
}
else if (childName.equals(SchemaSymbols.ELT_ATTRIBUTE) ||
childName.equals(SchemaSymbols.ELT_ATTRIBUTEGROUP)) {
break; // attr processing is done later on in this method
}
else if (childName.equals(SchemaSymbols.ELT_ANY)) {
index = traverseAny(child);
seeParticle = true;
seeOtherParticle = true;
}
else if (childName.equals(SchemaSymbols.ELT_ANNOTATION)) {
//REVISIT, do nothing for annotation for now.
}
else if (childName.equals(SchemaSymbols.ELT_ANYATTRIBUTE)) {
break;
//REVISIT, do nothing for attribute wildcard for now.
}
else { // datatype qual
if (!baseIsComplexSimple )
if (base.equals(""))
reportSchemaError(SchemaMessageProvider.GenericError,
new Object [] { "unrecognized child '"+childName+"' in complex type "+typeName });
else
reportSchemaError(SchemaMessageProvider.GenericError,
new Object [] { "unrecognized child '"+childName+"' in complex type '"+typeName+"' with base "+base });
}
// if base is complextype with simpleType content, can't have any particle children at all.
if (baseIsComplexSimple && seeParticle) {
// REVISIT: Localize
reportGenericSchemaError("In complexType "+typeName+", base type is complexType with simpleType content, can't have any particle children at all");
hadContent = false;
left = index = -2;
contentSpecType = XMLElementDecl.TYPE_SIMPLE;
break;
}
if (seeAll && seeOtherParticle) {
// REVISIT: Localize
reportGenericSchemaError ( " 'All' group needs to be the only child in Complextype : " + typeName);
}
if (seeAll) {
//TO DO: REVISIT
//check the minOccurs = 1 and maxOccurs = 1
}
// check the minOccurs and maxOccurs of the particle, and fix the
// contentspec accordingly
if (seeParticle) {
index = expandContentModel(index, child);
if (index == -2 ) {
continue;
}
} //end of if (seeParticle)
if (left == -2) {
left = index;
} else if (right == -2) {
right = index;
} else {
left = fSchemaGrammar.addContentSpecNode(csnType, left, right, false);
right = index;
}
} //end looping through the children
if ( ! ( seeOtherParticle || seeAll ) && (elementContent || mixedContent)
&& (base.length() == 0 || ( base.length() > 0 && derivedByRestriction && !baseIsComplexSimple)) ) {
contentSpecType = XMLElementDecl.TYPE_SIMPLE;
simpleTypeValidator = getDatatypeValidator("", SchemaSymbols.ATTVAL_STRING);
// REVISIT: Localize
reportGenericSchemaError ( " complexType '"+typeName+"' with a elementOnly or mixed content "
+"need to have at least one particle child");
}
if (hadContent && right != -2)
left = fSchemaGrammar.addContentSpecNode(csnType, left, right, false);
if (mixedContent && hadContent) {
// set occurrence count
left = fSchemaGrammar.addContentSpecNode(XMLContentSpec.CONTENTSPECNODE_ZERO_OR_MORE,
left, -1, false);
}
}
// if derived by extension and base complextype has a content model,
// compose the final content model by concatenating the base and the
// current in sequence.
if (!derivedByRestriction && baseContentSpecHandle > -1 ) {
if (baseFromAnotherSchema ) {
SchemaGrammar aGrammar = (SchemaGrammar) fGrammarResolver.getGrammar(baseTypeSchemaURI);
baseContentSpecHandle = importContentSpec(aGrammar, baseContentSpecHandle);
}
if (left == -2) {
left = baseContentSpecHandle;
}
else
left = fSchemaGrammar.addContentSpecNode(XMLContentSpec.CONTENTSPECNODE_SEQ,
baseContentSpecHandle,
left,
false);
}
// REVISIT: this is when sees a topelevel <complexType name="abc">attrs*</complexType>
if (content.length() == 0 && base.length() == 0 && left == -2) {
contentSpecType = XMLElementDecl.TYPE_ANY;
}
if (content.length() == 0 && simpleTypeValidator == null && left == -2 ) {
if (base.length() > 0 && baseTypeInfo != null
&& baseTypeInfo.contentType == XMLElementDecl.TYPE_EMPTY) {
contentSpecType = XMLElementDecl.TYPE_EMPTY;
}
}
if ( DEBUGGING )
System.out.println("!!!!!>>>>>" + typeName+", "+ baseTypeInfo + ", "
+ baseContentSpecHandle +", " + left +", "+scopeDefined);
ComplexTypeInfo typeInfo = new ComplexTypeInfo();
typeInfo.baseComplexTypeInfo = baseTypeInfo;
typeInfo.baseDataTypeValidator = baseTypeValidator;
int derivedByInt = -1;
if (derivedBy.length() > 0) {
derivedByInt = parseComplexDerivedBy(derivedBy);
}
typeInfo.derivedBy = derivedByInt;
typeInfo.scopeDefined = scopeDefined;
typeInfo.contentSpecHandle = left;
typeInfo.contentType = contentSpecType;
typeInfo.datatypeValidator = simpleTypeValidator;
typeInfo.blockSet = parseBlockSet(complexTypeDecl.getAttribute(SchemaSymbols.ATT_BLOCK));
typeInfo.finalSet = parseFinalSet(complexTypeDecl.getAttribute(SchemaSymbols.ATT_FINAL));
typeInfo.isAbstract = isAbstract.equals(SchemaSymbols.ATTVAL_TRUE) ? true:false ;
//add a template element to the grammar element decl pool.
int typeNameIndex = fStringPool.addSymbol(typeName);
int templateElementNameIndex = fStringPool.addSymbol("$"+typeName);
typeInfo.templateElementIndex =
fSchemaGrammar.addElementDecl(new QName(-1, templateElementNameIndex,typeNameIndex,fTargetNSURI),
(fTargetNSURI==-1) ? -1 : fCurrentScope, scopeDefined,
contentSpecType, left,
-1, simpleTypeValidator);
typeInfo.attlistHead = fSchemaGrammar.getFirstAttributeDeclIndex(typeInfo.templateElementIndex);