Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

XmlReader.Read produce an exception

2 views
Skip to first unread message

knoxi

unread,
Jul 2, 2009, 8:29:01 AM7/2/09
to

Hi

We have the following problem:
We get at the validation of an XML file against the corresponding schema
an internal exception in the XML reader. (Validation of an XML file
according to
MSDN Help)
The exception occurs also in the Visual Studio designer, this exception
appears in the
Error list when the XML file is loaded with the schema.
The XML and the schema should be valid.

It occurs with the following XML file and schema: open Trans 2.1fd
-> Http://www.opentrans.org/
-> \ Documents and files \ files openTRANS 2.1 \ openTRANS 2.1 (final draft
- draft) \ openTRANS 2.1fd english all-in-one package

These are the schema and a sample file, which we want to validate.

Can someone confirm this error?

How can I fix this error in Visual Studio or in my code?

Bye
knoxi

Martin Honnen

unread,
Jul 2, 2009, 8:56:05 AM7/2/09
to

knoxi wrote:

> We have the following problem:
> We get at the validation of an XML file against the corresponding schema
> an internal exception in the XML reader. (Validation of an XML file
> according to
> MSDN Help)
> The exception occurs also in the Visual Studio designer, this exception
> appears in the
> Error list when the XML file is loaded with the schema.

Which exception exactly do you get?
Which code exactly do you use to try to validate?

--

Martin Honnen --- MVP XML
http://msmvps.com/blogs/martin_honnen/

knoxi

unread,
Jul 2, 2009, 10:01:09 AM7/2/09
to

"Martin Honnen" wrote:

> Which exception exactly do you get?

Object reference not set to an instance of an object

> Which code exactly do you use to try to validate?

I used following code:

Dim XMLDoc As IO.TextReader = New IO.TextReader(pathXMLfile)
Dim schemaSet As New Xml.Schema.XmlSchemaSet()
schemaSet.Add(Nothing, New XmlTextReader(New IO.StringReader(strXSD)))
schemaSet.Compile()

'define settings for load xml
Dim settings As New Xml.XmlReaderSettings
AddHandler settings.ValidationEventHandler, AddressOf
ValidationCallBack
settings.ValidationType = Xml.ValidationType.Schema
settings.ValidationFlags =
Xml.Schema.XmlSchemaValidationFlags.ReportValidationWarnings
settings.Schemas = schemaSet

'load xml
m_xmlReader = New Xml.XmlTextReader(XMLDoc)
Using xmlReader As Xml.XmlReader = Xml.XmlReader.Create(m_xmlReader,
settings)
'read xml with validation
Do While xmlReader.Read() '-> here the exception occures when
the reader steps over xml-line 32 (element: PHONE)
' step over xml file
Loop
End Using

Bye
knoxi

0 new messages