473,386 Members | 1,973 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Prescise error messages from XmlValidatingReader - possible or not?

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
Feb 9 '06 #1
1 1288
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."

Feb 10 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Bill Cohagan | last post by:
I'm writing a console app in c# and am encountering a strange problem. I'm trying to use redirection of the standard input stream to read input from a (xml) file. The following code snippet is from...
0
by: Sangeetha Nagaraj | last post by:
Hi, I am writing a program to validate a XML file and i am getting an error. Here is my Code, and i get an error at "args.Exception" ("The 'urn:books:catalog' element is not declared. An error...
3
by: Amar | last post by:
Hi everyone, I am trying now for 4-5 hours to write a simple code to validate a very simple XML and i still get an error. Here is my Code, and i always get an error at args.Exception ("The...
4
by: Jesse Elve | last post by:
I am using an XmlValidatingReader which uses an XSD for xml validation. The code has been performing reliably for months. Yesterday it failed for the first time with the following exception: ...
2
by: matthew.schneider | last post by:
I have a defined XML Schema, and XML documents containing data that I validate against it. Periodically, I will have a data document that will contain extra elements that are not part of my schema....
5
by: Patrick | last post by:
I understand it is built in behaviour that if an ASP.NET's web.config is set to: <customErrors mode="RemoteOnly" /> then I only get a detailed error message on screen when the ASP.NET...
0
by: John Harcourt | last post by:
When I run the XML Validation against a schema using the XMLValidatingReader (.NET 1.1), the error messages that are produced are pretty generic. If I have an element name "LastName", and the...
1
by: BillAtWork | last post by:
Hi, I'm trying to validate an XML document against an XSD schema and I receive the following error: ---------- MyCode.CreateValidRequest : System.Web.Services.Protocols.SoapException :...
1
by: BillAtWork | last post by:
Hi, I'm trying to validate an XML document against an XSD schema and I receive the following error: ---------- MyCode.CreateValidRequest : System.Web.Services.Protocols.SoapException :...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.