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
QName group = element.getSubstitutionGroup();
if (group != null) {
ElementElement base = m_validationContext.findElement(group);
DefinitionItem basedef = ((GlobalExtension)base.getExtension()).getDefinition();
elmapping.setExtendsName(basedef.getGenerateClass().getFullName());
}
// create single structure child invoking the type mapping
holder = m_bindingDirectory.getRequiredBinding(elschema);