if (location == null) {
throw new IllegalArgumentException("location cannot be null");
}
Structure parent = null;
switch (structure.getStructureType()) {
case Structure.ELEMENT:
parent = ((ElementDecl) structure).getParent();
if (parent.getStructureType() != Structure.SCHEMA) {
getSchemaLocation(parent, location, dealWithAnonTypes);
}
location.append(ExtendedBinding.PATH_SEPARATOR);
location.append(((ElementDecl) structure).getName());
if (parent instanceof Schema) {
Schema schema = (Schema) parent;
if (schema.getTargetNamespace() != null) {
String targetNamespace = schema.getTargetNamespace();
location.append("{" + targetNamespace + "}");
}
}
break;
case Structure.COMPLEX_TYPE:
ComplexType complexType = (ComplexType) structure;
parent = (complexType).getParent();
if (parent.getStructureType() != Structure.SCHEMA) {
getSchemaLocation(parent, location, dealWithAnonTypes);
}
if (complexType.getName() != null) {
location.append(ExtendedBinding.PATH_SEPARATOR);
location.append(ExtendedBinding.COMPLEXTYPE_ID);
location.append(((ComplexType) structure).getName());
}
// else if (dealWithAnonTypes){
// location.append(ExtendedBinding.PATH_SEPARATOR);
// location.append(ExtendedBinding.COMPLEXTYPE_ID);
// location.append("anonymous");
// }
break;
case Structure.SIMPLE_TYPE:
SimpleType simpleType = (SimpleType) structure;
parent = simpleType.getParent();
if (parent != null && parent.getStructureType() != Structure.SCHEMA) {
getSchemaLocation(parent, location, dealWithAnonTypes);
}
if (parent != null && simpleType.getName() != null) {
location.append(ExtendedBinding.PATH_SEPARATOR);
location.append(ExtendedBinding.ENUMTYPE_ID);
location.append(((SimpleType) structure).getName());
}
// else if (dealWithAnonTypes){
// location.append(ExtendedBinding.PATH_SEPARATOR);
// location.append(ExtendedBinding.ENUMTYPE_ID);
// location.append("anonymous");
// }
break;
case Structure.MODELGROUP:
ModelGroup group = (ModelGroup) structure;
parent = group.getParent();
if (parent.getStructureType() != Structure.SCHEMA) {
getSchemaLocation(parent, location, dealWithAnonTypes);
}
if (group.getName() != null) {
location.append(ExtendedBinding.PATH_SEPARATOR);
location.append(ExtendedBinding.GROUP_ID);
location.append(group.getName());
}
break;
case Structure.ATTRIBUTE:
parent = ((AttributeDecl) structure).getParent();
if (parent.getStructureType() != Structure.SCHEMA) {
getSchemaLocation(parent, location, dealWithAnonTypes);
}
location.append(ExtendedBinding.PATH_SEPARATOR);
location.append(ExtendedBinding.ATTRIBUTE_PREFIX);
location.append(((AttributeDecl) structure).getName());