public XmlSchemaComplexType CreateDataType(DataType dataType) { // create types XmlSchemaComplexType complexType = new XmlSchemaComplexType(); complexType.Name = dataType.Name; complexType.AddSchemaDocumentation(dataType.Description); CogsSchema.Items.Add(complexType); XmlSchemaSequence itemElements = new XmlSchemaSequence(); if (dataType.IsAbstract) { complexType.IsAbstract = true; } if (!string.IsNullOrWhiteSpace(dataType.ExtendsTypeName)) { XmlSchemaComplexContent complexContent = new XmlSchemaComplexContent(); complexType.ContentModel = complexContent; XmlSchemaComplexContentExtension contentExtension = new XmlSchemaComplexContentExtension(); complexContent.Content = contentExtension; contentExtension.BaseTypeName = new XmlQualifiedName(dataType.ExtendsTypeName, TargetNamespace); contentExtension.Particle = itemElements; } else { complexType.Particle = itemElements; } foreach (var property in dataType.Properties) { if (property.Name == "space") { continue;//TODO } CreateElementReference(itemElements, property); } return(complexType); }
XmlSchemaComplexType CreateItemContainerType(out XmlSchemaChoice itemChoices) { // Item Container type XmlSchemaComplexType containerType = new XmlSchemaComplexType(); containerType.Name = "ItemContainerType"; containerType.AddSchemaDocumentation("Used for serializing a set of items."); var sequence = new XmlSchemaSequence(); containerType.Particle = sequence; // Top level reference element XmlSchemaElement element = new XmlSchemaElement(); element.Name = "TopLevelReference"; element.SchemaTypeName = new XmlQualifiedName("ReferenceType", TargetNamespace); element.AddSchemaDocumentation("Denote which items in the Fragment Instance are the main items of interest."); CogsSchema.Items.Add(element); // include top level reference XmlSchemaElement elementRef = new XmlSchemaElement(); elementRef.RefName = new XmlQualifiedName("TopLevelReference", TargetNamespace); elementRef.MinOccurs = 0; elementRef.MaxOccursString = "unbounded"; sequence.Items.Add(elementRef); itemChoices = new XmlSchemaChoice(); itemChoices.MinOccurs = 0; itemChoices.MaxOccursString = "unbounded"; sequence.Items.Add(itemChoices); return(containerType); }