public static XmlSchema GenerateXSD(GeneratorContext context) { string targetNameSpace = NDR.getTargetNameSpace(context, false); IMa documentRoot = context.DocLibrary.DocumentRoot; var schema = new XmlSchema { TargetNamespace = targetNameSpace }; //namespaces schema.Namespaces.Add("xsd", "http://www.w3.org/2001/XMLSchema"); schema.Namespaces.Add(context.NamespacePrefix, targetNameSpace); //qualifiedSetting schema.ElementFormDefault = XmlSchemaForm.Qualified; schema.AttributeFormDefault = XmlSchemaForm.Unqualified; //version schema.Version = context.DocLibrary.VersionIdentifier.DefaultTo("1"); string schemaFileName = getSchemaFileName(context, false); AddRootElementDeclaration(schema, documentRoot, context); GenerateComplexTypeForMa(context, schema, documentRoot); //non root elements, not used IEnumerable <IMa> nonRootDocLibraryElements = context.DocLibrary.NonRootMas; AddGlobalTypeDefinitions(schema, nonRootDocLibraryElements, context); AddGlobalElementDeclarations(schema, nonRootDocLibraryElements, context); context.AddSchema(schema, schemaFileName, UpccSchematype.ROOT); return(schema); }