The only problem that I see is that Read is a static function. Following
code works for me:
Imports System
Imports System.IO
Imports System.Xml
Imports System.Xml.Schema
Module Module1
Dim s = "<xs:schema targetNamespace='uri_tns'
xmlns:xs='http://www.w3.org/2001/XMLSchema'><xs:element name='foo'
type='xs:string' /><xs:attribute name='bar' type='xs:int' /></xs:schema>"
Sub Main()
Dim schema As XmlSchema
schema = XmlSchema.Read(New StringReader(s), AddressOf
ValidationCallbackOne)
schema.Compile(AddressOf ValidationCallbackOne)
schema.Write(Console.Out)
End Sub
Sub ValidationCallbackOne(ByVal sender As Object, ByVal args As
ValidationEventArgs)
Console.WriteLine(args.Message)
End Sub 'ValidationCallbackOne
End Module
"Stefan Rotter" <st****@vemendo.se> wrote in message
news:bf**************************@posting.google.c om...
Hi,
I'm trying to load a schema into an XmlSchema object with the Read and
Compile methods. I use Read with a ValidationEventHandler. No errors
occurs but when I look at the XmlSchema properties it contains
NOTHING. The schema file is correct because I can use it to validate
xmldocuments with the XMLValidatingReader. What am I doing wrong here?
Code:
Dim xs As New Xml.Schema.XmlSchema()
Dim fs = New IO.FileStream("test.xsd", IO.FileMode.Open)
xs.Read(fs, New Xml.Schema.ValidationEventHandler(AddressOf
ValidationCallback))
xs.Compile(AddressOf ValidationCallback)
Thanks in advance,
Stefan