public override XmlDocument NewInstance(string rootElement)
{
List<SchemaRelease> releases = new List<SchemaRelease> ();
SchemaRelease mainSchema = null;
FindAllImports (releases);
foreach (SchemaRelease release in releases) {
if (release.HasRootElement (rootElement)) {
if (mainSchema != null) {
log.Fatal ("Multiple schemas define root element '" + rootElement + "'");
return (null);
}
mainSchema = release;
}
}
if (mainSchema == null) {
log.Fatal ("No schema recognised '" + rootElement + "' as a root element.");
return (null);
}
XmlDocument document = new XmlDocument ();
XmlElement element = document.CreateElement (rootElement, namespaceUri);
element.SetAttribute ("xmlns:xsi", INSTANCE_URL);
document.AppendChild (element);
foreach (SchemaRelease release in releases)
release.initialiser.Initialise (release, element, release == mainSchema);
return (document);
}