* All schemas that are included have to have the same target namespace as the including schema (this is a requirement in XSD)
* Your ContainsTypeName method (in Xsd2Code.Library.Extensions.CodeExtension.cs) checks for namespace equality
Therefore ALL types in the XSD files (directly or through includes) are classified as directly in the same file by your logic. This should be fixed.
Comments: ** Comment from web user: jparson **
Keeping in mind that I don't have a lot of experience with XSD or CodeDom and have probably overlooked something, I have a fix for this.
I altered the Xsd2Code.Library.Extensions.CodeExtension.Process() function to compare the type names from the passed in XslSchema object and the type names contained in the XslSchema.Includes collection. If the names are in both locations, I remove it from the passed in CodeNamespace.Types object.
Original Code:
```
foreach (var type in types)
{
...
// Fixes http://xsd2code.codeplex.com/WorkItem/View.aspx?WorkItemId=8781
// and http://xsd2code.codeplex.com/WorkItem/View.aspx?WorkItemId=6944
if (GeneratorContext.GeneratorParams.Miscellaneous.ExcludeIncludedTypes)
{
//if the typeName is NOT defined in the current schema, skip it.
if (!ContainsTypeName(schema, type))
{
code.Types.Remove(type);
continue;
}
}
...
}
```
Altered Code:
```
List<String> lstBaseXmlTypes = new List<String>();
List<String> lstIncludedXmlTypes = new List<String>();
// Get all type names in the schema
foreach (var name in schema.SchemaTypes.Names)
lstBaseXmlTypes.Add(name.ToString());
// Get all type names from all schemas in the Includes collection
foreach (XmlSchemaInclude i in schema.Includes)
// loop through all schemas in the Includes collection
foreach (XmlSchemaInclude i in schema.Includes)
// Get all type names from each schema
foreach (var name in i.Schema.SchemaTypes.Names)
if (!lstIncludedXmlTypes.Contains(name.ToString()))
lstIncludedXmlTypes.Add(name.ToString());
foreach (var type in types)
{
...
if (GeneratorContext.GeneratorParams.Miscellaneous.ExcludeIncludedTypes)
{
// Remove types from the CodeDom if found in both type lists.
if (lstIncludedXmlTypes.Contains(type.Name) && lstBaseXmlTypes.Contains(type.Name))
{
code.Types.Remove(type);
continue;
}
}
...
}
```