views:

63

answers:

0

Hi,

My XmlSchemaSet add method is being ignored. TargetNamespace probably already exists.

In my loop (part of GetSchema) I am adding existing classes to the XmlSchemaSet

public static System.Xml.Schema.XmlSchemaType GetSchema(System.Xml.Schema.XmlSchemaSet xs) {
            XsdDataContractExporter exporter = new XsdDataContractExporter();
            exporter.Export(typeof(T));
            XmlQualifiedName name = exporter.GetRootElementName(typeof(T));
            foreach (XmlSchema sc in exporter.Schemas.Schemas())
                xs.Add(sc);

            // Add more complex types and so on
            // using types in the exported data.
}

The add method appears to be ignoring the xs.Add(sc) line of code because it believes that the schema already exists, probably because there are other classes in the schema with the same TargetNamespace.

How do I merge the schemas from exporter.Export with the schemas already present in (xs)

The add method doesn't actually merge.

Thanks