XmlSchema validation call back
Imports System Imports System.IO Imports System.Text Imports System.Xml Imports System.Xml.Schema Class MainClass Shared Sub Main() Try Dim reader As XmlTextReader = New XmlTextReader("example.xsd") Dim myschema As XmlSchema = XmlSchema.Read(reader, AddressOf ValidationCallback) myschema.Write(Console.Out) Dim file As FileStream = New FileStream("new.xsd", FileMode.Create, FileAccess.ReadWrite) Dim xwriter As XmlTextWriter = New XmlTextWriter(file, New UTF8Encoding()) xwriter.Formatting = Formatting.Indented myschema.Write(xwriter) Catch e As Exception Console.WriteLine(e) End Try End Sub Shared Sub ValidationCallback(ByVal sender As Object, ByVal args As ValidationEventArgs) If args.Severity = XmlSeverityType.Warning Then Console.Write("WARNING: "+args.Message) Else If args.Severity = XmlSeverityType.Error Then Console.Write("ERROR: "+args.Message) End If End Sub End Class 'The example takes the example.xsd as input. '<?xml version="1.0"?> '<xs:schema id="test" ' targetNamespace="http://tempuri.org/play.xsd" ' elementFormDefault="qualified" ' xmlns="http://tempuri.org/play.xsd" ' xmlns:xs="http://www.w3.org/2001/XMLSchema"> ' <xs:element name='myShoeSize'> ' <xs:complexType> ' <xs:simpleContent> ' <xs:extension base='xs:decimal'> ' <xs:attribute name='sizing' type='xs:string' /> ' </xs:extension> ' </xs:simpleContent> ' </xs:complexType> ' </xs:element> '</xs:schema>