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;
}
else
{
EAttribute eAttribute = ecoreFactory.createEAttribute();
setAnnotations(eAttribute, xsdComponent);
eAttribute.setName(Character.toLowerCase(name.charAt(0)) + name.substring(1));
eAttribute.setUnique(false);
eAttribute.setEType(type);
eAttribute.setLowerBound(minOccurs);
eAttribute.setUpperBound(maxOccurs);
eClass.getEStructuralFeatures().add(eAttribute);
if (xsdComponent == null || xsdComponent instanceof XSDSimpleTypeDefinition)
{
extendedMetaData.setName(eAttribute, ":" + eClass.getEAllStructuralFeatures().indexOf(eAttribute));
extendedMetaData.setFeatureKind(eAttribute, ExtendedMetaData.SIMPLE_FEATURE);
}
else
{
map(xsdComponent, eAttribute);
if (xsdComponent instanceof XSDAttributeUse)
{
XSDAttributeUse xsdAttributeUse = (XSDAttributeUse)xsdComponent;
XSDAttributeDeclaration xsdAttributeDeclaration = xsdAttributeUse.getAttributeDeclaration();
extendedMetaData.setFeatureKind(eAttribute, ExtendedMetaData.ATTRIBUTE_FEATURE);
extendedMetaData.setName(eAttribute, xsdAttributeDeclaration.getName());
extendedMetaData.setNamespace(eAttribute, xsdAttributeDeclaration.getTargetNamespace());
String defaultValue = getEcoreAttribute(xsdComponent, "default");
if (defaultValue == null)
{
defaultValue = xsdAttributeUse.getLexicalValue();
}
eAttribute.setDefaultValueLiteral(defaultValue);
initialize(eAttribute, (XSDSimpleTypeDefinition)getEffectiveTypeDefinition(xsdAttributeUse, xsdAttributeDeclaration));
}
else if (xsdComponent instanceof XSDAttributeDeclaration)
{
XSDAttributeDeclaration xsdAttributeDeclaration = (XSDAttributeDeclaration)xsdComponent;
extendedMetaData.setFeatureKind(eAttribute, ExtendedMetaData.ATTRIBUTE_FEATURE);
extendedMetaData.setName(eAttribute, xsdAttributeDeclaration.getName());
extendedMetaData.setNamespace(eAttribute, xsdAttributeDeclaration.getTargetNamespace());
eAttribute.setDefaultValueLiteral(xsdAttributeDeclaration.getLexicalValue());
initialize(eAttribute, (XSDSimpleTypeDefinition)getEffectiveTypeDefinition(null, xsdAttributeDeclaration));
}
else if (xsdComponent instanceof XSDParticle)
{
XSDTerm xsdTerm = ((XSDParticle)xsdComponent).getTerm();
if (xsdTerm instanceof XSDElementDeclaration)
{
XSDElementDeclaration xsdElementDeclaration = (XSDElementDeclaration)xsdTerm;
extendedMetaData.setFeatureKind(eAttribute, ExtendedMetaData.ELEMENT_FEATURE);
extendedMetaData.setName(eAttribute, xsdElementDeclaration.getName());
extendedMetaData.setNamespace(eAttribute, xsdElementDeclaration.getTargetNamespace());
eAttribute.setDefaultValueLiteral(xsdElementDeclaration.getLexicalValue());
XSDTypeDefinition xsdType = getEffectiveTypeDefinition(xsdComponent, xsdElementDeclaration);
if (xsdType instanceof XSDSimpleTypeDefinition)
{
initialize(eAttribute, (XSDSimpleTypeDefinition)xsdType);
}
if (xsdElementDeclaration.isNillable())
{
if (!canSupportNull((EDataType)type))
{
eAttribute.setEType(type = (EDataType)typeToTypeObjectMap.get(type));
}
if (maxOccurs == 1)
{
eAttribute.setUnsettable(true);
}
}
if (xsdElementDeclaration.isAbstract())
{
eAttribute.setChangeable(false);
}
}
else if (xsdTerm instanceof XSDWildcard)
{
XSDWildcard xsdWildcard = (XSDWildcard)xsdTerm;
extendedMetaData.setFeatureKind(eAttribute, ExtendedMetaData.ELEMENT_WILDCARD_FEATURE);
extendedMetaData.setWildcards(eAttribute, getWildcards(xsdWildcard));
extendedMetaData.setProcessingKind(eAttribute, xsdWildcard.getProcessContents().getValue() + 1);
extendedMetaData.setName(eAttribute, ":" + eClass.getEAllStructuralFeatures().indexOf(eAttribute));
}
else
{
extendedMetaData.setFeatureKind(eAttribute, ExtendedMetaData.GROUP_FEATURE);
}
}
else if (xsdComponent instanceof XSDWildcard)
{
XSDWildcard xsdWildcard = (XSDWildcard)xsdComponent;
extendedMetaData.setFeatureKind(eAttribute, ExtendedMetaData.ATTRIBUTE_WILDCARD_FEATURE);
extendedMetaData.setWildcards(eAttribute, getWildcards(xsdWildcard));
extendedMetaData.setProcessingKind(eAttribute, xsdWildcard.getProcessContents().getValue() + 1);
extendedMetaData.setName(eAttribute, ":" + eClass.getEAllStructuralFeatures().indexOf(eAttribute));
}
else if (xsdComponent instanceof XSDElementDeclaration)
{
XSDElementDeclaration xsdElementDeclaration = (XSDElementDeclaration)xsdComponent;
extendedMetaData.setFeatureKind(eAttribute, ExtendedMetaData.ELEMENT_FEATURE);
extendedMetaData.setName(eAttribute, xsdElementDeclaration.getName());
extendedMetaData.setNamespace(eAttribute, xsdElementDeclaration.getTargetNamespace());
eAttribute.setDefaultValueLiteral(xsdElementDeclaration.getLexicalValue());
XSDTypeDefinition xsdType = getEffectiveTypeDefinition(null, xsdElementDeclaration);
if (xsdType instanceof XSDSimpleTypeDefinition)
{
initialize(eAttribute, (XSDSimpleTypeDefinition)xsdType);
}
XSDElementDeclaration substitutionGroupAffiliation = xsdElementDeclaration.getSubstitutionGroupAffiliation();
if (substitutionGroupAffiliation != null)
{
EStructuralFeature affiliation = getEStructuralFeature(substitutionGroupAffiliation);
extendedMetaData.setAffiliation(eAttribute, affiliation);
}