Reading XML Schema and schemas located in Includes
-
I'm writing a C# app to document the types of XmlSchemaComplex types... I have a schema file containing complexTypes, and those complexTypes have elements which are of other complexTypes, located in another file that I'm including into my outer schema file. I'm reading the schema file, going into the complexTypes, and trying to read the types of the sub-elements that are of the sub-types. However, the type attributes of the elements inside my main complexTypes are set to nulls, although the SchemaTypeText is filled out with the current type name and namespace. The code that I'm using looks a little something like this (please pardon the horrendous noobishness): XmlTextReader schemaReader = new XmlTextReader(schemaPath); XmlSchema schema = XmlSchema.Read(schemaReader, null); foreach (XmlSchemaObject xso in schema.Items) { if (xso is XmlSchemaComplexType) { XmlSchemaComplexType rootType = xso as XmlSchemaComplexType; if (rootType.Particle is XmlSchemaSequence) { XmlSchemaSequence rootseq = (XmlSchemaSequence)rootType.Particle; foreach(XmlSchemaObject ixso in rootseq.Items) { if (ixso is XmlSchemaElement) { XmlSchemaElement ele = ixso as XmlSchemaElement; XmlSchemaType eleType = ele.SchemaType; // this is null string typTxt = ele.SchemaTypeText; // this right, but strings. } } } } If I can get the part about accessing the element types of the nested elements in my complexTypes right, I want to pass those complexTypes into a recursive method that'll enumerate all the members of the inner complexTypes for me, etc.