Mega Code Archive
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.
'
'
'
'
'
'
'
'
'
'
'
'