public void ShouldGenerateASchemaToValidateTestSubClassXml() { NetReflectorTypeTable table = new NetReflectorTypeTable { typeof (TestClass), typeof (TestInnerClass), typeof (TestSubClass) }; XsdGenerator generator = new XsdGenerator(table); XmlSchema schema = generator.Generate(true); #if DEBUG schema.Write(Console.Out); #endif string xmlToValidate = TestClass.GetXmlWithSubClass(DateTime.Today); #if DEBUG Console.Out.WriteLine("xmlToValidate = {0}", xmlToValidate); #endif XmlValidatingReader reader = new XmlValidatingReader(new XmlTextReader(new StringReader(xmlToValidate))); reader.Schemas.Add(schema); reader.ValidationType = ValidationType.Schema; while (reader.Read()) {} }
public XmlSchemaElement GenerateElement() { var element = new XmlSchemaElement { Name = ElementName, SchemaTypeName = new XmlQualifiedName(TypeName, NamespaceUri) }; XsdGenerator.AddDocumentation(Description, element); return(element); }