force XML to get validated against an XSD schema?
-
I'm using C# (.NET 2.0 framework).. Is it possible to force an XML file that doesn't reference an XSD schema to be validated against a specified XSD schema? Here is a code segment I'm using:
XmlSchema schema = XmlSchema.Read(
new StringReader(MySchemaStringTextBox.Text),
ValidationCallback);XmlReaderSettings readerSettings = new XmlReaderSettings();
readerSettings.Schemas.Add(schema);
readerSettings.ValidationType = ValidationType.Schema;
readerSettings.ValidationFlags = XmlSchemaValidationFlags.None;XmlReader configReader = XmlReader.Create(new StringReader(MyXmlTextBox.Text), readerSettings);
XmlDocument config = new XmlDocument();
config.Load(configReader);
config.Validate(new ValidationEventHandler(ValidationCallback));ValidationCallback never gets called, unless a schema is actually specified in the XML file. Thanks in advance!
r -€