extendedMetaData.setName(eAttribute, ":" + eAttribute.getName());
return eAttribute;
}
else
{
EReference eReference = ecoreFactory.createEReference();
setAnnotations(eReference, xsdComponent);
eReference.setName(name);
eReference.setEType(ecorePackage.getEStringToStringMapEntry());
eReference.setLowerBound(0);
eReference.setUpperBound(-1);
eReference.setContainment(true);
eReference.setResolveProxies(false);
eReference.setTransient(true);
eClass.getEStructuralFeatures().add(eReference);
extendedMetaData.setFeatureKind(eReference, ExtendedMetaData.ATTRIBUTE_FEATURE);
return eReference;
}
}
if (type instanceof EClass)
{
EReference eReference = ecoreFactory.createEReference();
setAnnotations(eReference, xsdComponent);
eReference.setName(Character.toLowerCase(name.charAt(0)) + name.substring(1));
eReference.setEType(type);
eReference.setLowerBound(minOccurs);
eReference.setUpperBound(maxOccurs);
eClass.getEStructuralFeatures().add(eReference);
if (xsdComponent == null || xsdComponent instanceof XSDSimpleTypeDefinition)
{
extendedMetaData.setName(eReference, ":" + eClass.getEAllStructuralFeatures().indexOf(eReference));
extendedMetaData.setFeatureKind(eReference, ExtendedMetaData.SIMPLE_FEATURE);
eReference.setResolveProxies(!isLocalReferenceType((XSDSimpleTypeDefinition)xsdComponent));
}
else
{
map(xsdComponent, eReference);
if (xsdComponent instanceof XSDParticle)
{
eReference.setContainment(true);
eReference.setResolveProxies(false);
XSDParticle xsdParticle = (XSDParticle)xsdComponent;
XSDTerm xsdTerm = ((XSDParticle)xsdComponent).getTerm();
if (xsdTerm instanceof XSDElementDeclaration)
{
XSDElementDeclaration xsdElementDeclaration = (XSDElementDeclaration)xsdTerm;
extendedMetaData.setFeatureKind(eReference, ExtendedMetaData.ELEMENT_FEATURE);
extendedMetaData.setName(eReference, xsdElementDeclaration.getName());
extendedMetaData.setNamespace(eReference, xsdElementDeclaration.getTargetNamespace());
XSDTypeDefinition xsdType = getEffectiveTypeDefinition(xsdParticle, xsdElementDeclaration);
if (xsdType instanceof XSDSimpleTypeDefinition)
{
eReference.setContainment(false);
eReference.setResolveProxies(!isLocalReferenceType((XSDSimpleTypeDefinition)xsdType));
}
if (maxOccurs == 1 && xsdElementDeclaration.isNillable())
{
eReference.setUnsettable(true);
}
if (xsdElementDeclaration.isAbstract())
{
eReference.setChangeable(false);
}
String opposite = getEcoreAttribute(xsdParticle, "opposite");
if (opposite != null)
{
eReferenceToOppositeNameMap.put(eReference, opposite);
}
}
else if (xsdTerm instanceof XSDWildcard)
{
// EATM shouldn't happen
XSDWildcard xsdWildcard = (XSDWildcard)xsdTerm;
extendedMetaData.setFeatureKind(eReference, ExtendedMetaData.ELEMENT_WILDCARD_FEATURE);
extendedMetaData.setWildcards(eReference, getWildcards(xsdWildcard));
extendedMetaData.setProcessingKind(eReference, xsdWildcard.getProcessContents().getValue() + 1);
extendedMetaData.setName(eReference, ":" + eClass.getEAllStructuralFeatures().indexOf(eReference));
}
else
{
extendedMetaData.setFeatureKind(eReference, ExtendedMetaData.GROUP_FEATURE);
extendedMetaData.setName(eReference, ":" + eClass.getEAllStructuralFeatures().indexOf(eReference));
}
}
else if (xsdComponent instanceof XSDElementDeclaration)
{
XSDElementDeclaration xsdElementDeclaration = (XSDElementDeclaration)xsdComponent;
eReference.setContainment(true);
eReference.setResolveProxies(false);
extendedMetaData.setFeatureKind(eReference, ExtendedMetaData.ELEMENT_FEATURE);
extendedMetaData.setName(eReference, xsdElementDeclaration.getName());
extendedMetaData.setNamespace(eReference, xsdElementDeclaration.getTargetNamespace());
XSDElementDeclaration substitutionGroupAffiliation = xsdElementDeclaration.getSubstitutionGroupAffiliation();
if (substitutionGroupAffiliation != null)
{
EStructuralFeature affiliation = getEStructuralFeature(substitutionGroupAffiliation);
extendedMetaData.setAffiliation(eReference, affiliation);
}
XSDTypeDefinition xsdType = getEffectiveTypeDefinition(null, xsdElementDeclaration);
if (xsdType instanceof XSDSimpleTypeDefinition)
{
eReference.setResolveProxies(!isLocalReferenceType((XSDSimpleTypeDefinition)xsdType));
}
if (maxOccurs == 1 && xsdElementDeclaration.isNillable())
{
eReference.setUnsettable(true);
}
if (xsdElementDeclaration.isAbstract())
{
eReference.setChangeable(false);
}
}
else if (xsdComponent instanceof XSDAttributeUse)
{
String opposite = getEcoreAttribute(xsdComponent, "opposite");
if (opposite != null)
{
eReferenceToOppositeNameMap.put(eReference, opposite);
}
XSDAttributeUse xsdAttributeUse = (XSDAttributeUse)xsdComponent;
XSDAttributeDeclaration xsdAttributeDeclaration = xsdAttributeUse.getAttributeDeclaration();
extendedMetaData.setFeatureKind(eReference, ExtendedMetaData.ATTRIBUTE_FEATURE);
extendedMetaData.setName(eReference, xsdAttributeDeclaration.getName());
extendedMetaData.setNamespace(eReference, xsdAttributeDeclaration.getTargetNamespace());
eReference.setResolveProxies
(!isLocalReferenceType((XSDSimpleTypeDefinition)getEffectiveTypeDefinition(xsdAttributeUse, xsdAttributeDeclaration)));
}
else if (xsdComponent instanceof XSDAttributeDeclaration)
{
XSDAttributeDeclaration xsdAttributeDeclaration = (XSDAttributeDeclaration)xsdComponent;
extendedMetaData.setFeatureKind(eReference, ExtendedMetaData.ATTRIBUTE_FEATURE);
extendedMetaData.setName(eReference, xsdAttributeDeclaration.getName());
extendedMetaData.setNamespace(eReference, xsdAttributeDeclaration.getTargetNamespace());
eReference.setResolveProxies
(!isLocalReferenceType((XSDSimpleTypeDefinition)getEffectiveTypeDefinition(null, xsdAttributeDeclaration)));
}
}
return eReference;