compactGroups(definition);
// build the binding component for this definition
ClassHolder clas = (ClassHolder)definition.getGenerateClass();
OpenAttrBase comp = definition.getSchemaComponent();
SchemaElement schema = comp.getSchema();
BindingHolder holder = m_bindingDirectory.getRequiredBinding(schema);
if (definition.isEnumeration()) {
// construct format and add to binding
FormatElement format = new FormatElement();
format.setTypeName(clas.getBindingName());
format.setQName(definition.getQName());
((EnumerationClassHolder)clas).setBinding(format);
m_bindingDirectory.addFormat(format);
} else {
// construct mapping element
MappingElementBase mapping = new MappingElement();
mapping.setClassName(clas.getBindingName());
if (comp.type() == SchemaBase.ELEMENT_TYPE) {
// abstract or concrete mapping for element
ElementElement element = (ElementElement)comp;
setName(element.getEffectiveQName(), mapping, holder);
mapping.setAbstract(element.isAbstract());
QName group = element.getSubstitutionGroup();
if (group != null) {
ElementElement base = m_validationContext.findElement(group);
DefinitionItem basedef = ((GlobalExtension)base.getExtension()).getDefinition();
mapping.setExtendsName(basedef.getGenerateClass().getFullName());
}
} else {
// abstract mapping for type definition or group
mapping.setAbstract(true);
QName qname = definition.getQName();
mapping.setTypeQName(qname);
String uri = qname.getUri();
if (uri != null) {
m_bindingDirectory.addTypeNameReference(holder, uri, schema);
}
}
// add the mapping to binding and set on class
holder.addMapping(mapping);
((StructureClassHolder)clas).setBinding(mapping);
DefinitionItem elementdef = (DefinitionItem)typeinst.get(definition);
if (elementdef != null) {
// create mapping for element name linked to type
ElementElement element = (ElementElement)elementdef.getSchemaComponent();
SchemaElement elschema = element.getSchema();
MappingElementBase elmapping = new MappingElement();
elmapping.setClassName(clas.getBindingName());
elmapping.setAbstract(element.isAbstract());
// handle linking to substitution group head using extends mapping