Prescise error messages from XmlValidatingReader - possible or not?

  • Thread starter Thread starter Wolfgang Uhr
  • Start date Start date
W

Wolfgang Uhr

Hello

I have the following problem.

I want to use the validating parser XmlValidatingReader and so I write ...

FileStream stream = new FileStream(ofd.FileName, FileMode.Open);
XmlValidatingReader rdr = new XmlValidatingReader(
stream, XmlNodeType.Element, null);
rdr.ValidationEventHandler += eventHandler;
rdr.ValidationType = ValidationType.Auto;
doc = new XmlDocument();
doc.Load(rdr);

This program works without a little exception.

I have a xsd-file - well formed and valid - and a xml-file based on that
xsd, well formed and valid too, both written and testet with atova xml spy.

But instead of this, the XmlValidatingReader throws errors. In the
eventhandler i get a message, that (translated from German) "Keyref
cannot find the 'key'- or 'unique'-Element, which is pointed out by
'selectionParameter'."

Independently of the problem - it is an xml-Problem and off Topic here -
I'm interested in writing a proper error message which contains the line
number of the xml file which produces the error. The xml-file has more
than 1000 lines and it is not a good idea to say "Somewhere in that file
there is something wrong"

Can you give me a hint to improve the quality of my error message.

Thanks and best regards
Wolfgang Uhr
 
Hi Wolfgang,

This might be the difference between .NET xml parse and the Xml spy parser.
Unfortunately, we can do nothing to improve the quality of the error
message, because it was generated from inside of the Xml parser. If you
need better error message, you might need to implement your own parser.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Back
Top