throw new SchemaCompilationException("can not find the type " + schemaTypeName +
" from the parent schema " + parentSchema.getTargetNamespace());
} else {
XmlSchemaType type = resolvedSchema.getTypeByName(schemaTypeName);
if (type instanceof XmlSchemaSimpleType) {
XmlSchemaSimpleType simpleType = (XmlSchemaSimpleType) type;
if (simpleType != null) {
if (!isAlreadyProcessed(schemaTypeName)) {
//process simple type
processSimpleSchemaType(simpleType, null, resolvedSchema, null);
}
metainf.registerMapping(att.getQName(),
schemaTypeName,
processedTypemap.get(schemaTypeName).toString(),
SchemaConstants.ATTRIBUTE_TYPE);
// add optional attribute status if set
String use = att.getUse().getValue();
if (USE_NONE.equals(use) || USE_OPTIONAL.equals(use)) {
metainf.addtStatus(att.getQName(), SchemaConstants.OPTIONAL_TYPE);
}
}
}
}
}
} else {
// this attribute has a type but does not have a name, seems to be invalid
}
} else if (att.getRefName() != null) {
XmlSchema resolvedSchema = getParentSchema(parentSchema,att.getRefName(),COMPONENT_ATTRIBUTE);
if (resolvedSchema == null){
throw new SchemaCompilationException("can not find the attribute " + att.getRefName() +
" from the parent schema " + parentSchema.getTargetNamespace());
} else {
XmlSchemaAttribute xmlSchemaAttribute =
(XmlSchemaAttribute) resolvedSchema.getAttributes().getItem(att.getRefName());
if (xmlSchemaAttribute != null) {
// call recursively to process the schema
processAttribute(xmlSchemaAttribute, metainf, resolvedSchema);
} else {
throw new SchemaCompilationException("Attribute QName reference refer to an invalid attribute " +
att.getRefName());
}
}
} else {
// this attribute refers to a custom type, probably one of the extended simple types.
// with the inline schema definition
QName attributeQName = att.getQName();
if (attributeQName != null) {
XmlSchemaSimpleType attributeSimpleType = att.getSchemaType();
XmlSchema resolvedSchema = parentSchema;
if (attributeSimpleType == null) {
// try to get the schema for using qname
QName attributeSchemaQname = att.getSchemaTypeName();
if (attributeSchemaQname != null) {
resolvedSchema = getParentSchema(parentSchema,attributeSchemaQname,COMPONENT_TYPE);
if (resolvedSchema == null){
throw new SchemaCompilationException("can not find the type " + attributeSchemaQname
+ " from the parent schema " + parentSchema.getTargetNamespace());
} else {
attributeSimpleType = (XmlSchemaSimpleType)
resolvedSchema.getTypeByName(attributeSchemaQname);
}
}
}
if (attributeSimpleType != null) {
QName schemaTypeQName = att.getSchemaTypeName();
if (schemaTypeQName == null) {
// set the parent schema target name space since attribute Qname uri is ""
if (attributeSimpleType.getQName() != null) {
schemaTypeQName = attributeSimpleType.getQName();
} else {
schemaTypeQName = new QName(parentSchema.getTargetNamespace(),
attributeQName.getLocalPart() + getNextTypeSuffix(attributeQName.getLocalPart()));
}