Imports System
Imports System.Xml
Imports System.Xml.Schema
Imports System.Xml.XPath
Public Class MainClass
Shared errors As Boolean = False
Private Shared Sub XSDErrors(ByVal o As Object, ByVal e As ValidationEventArgs)
Console.WriteLine("{0}", e.Message)
errors = True
End Sub
Public Shared Sub Main()
Dim xsdMarkup As XDocument = _
Dim schemas As XmlSchemaSet = New XmlSchemaSet()
schemas.Add("", xsdMarkup.CreateReader)
Dim doc1 As XDocument =
errors = False
doc1.Validate(schemas, AddressOf XSDErrors, True)
Console.WriteLine("doc1 {0}", IIf(errors, "did not validate", "validated"))
Dim lang As XAttribute = doc1.Root.Attribute("Lang")
errors = False
lang.Validate(lang.GetSchemaInfo().SchemaAttribute, schemas, AddressOf XSDErrors)
Console.WriteLine("lang {0}", IIf(errors, "did not validate", "validated"))
lang.Value = "VC"
errors = False
lang.Validate(lang.GetSchemaInfo().SchemaAttribute, schemas, AddressOf XSDErrors)
Console.WriteLine("lang {0}", IIf(errors, "did not validate", "validated"))
End Sub
End Class