473,804 Members | 3,277 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Prescise error messages from XmlValidatingRe ader - possible or not?

Hello

I have the following problem.

I want to use the validating parser XmlValidatingRe ader and so I write ...

FileStream stream = new FileStream(ofd. FileName, FileMode.Open);
XmlValidatingRe ader rdr = new XmlValidatingRe ader(
stream, XmlNodeType.Ele ment, null);
rdr.ValidationE ventHandler += eventHandler;
rdr.ValidationT ype = 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 XmlValidatingRe ader 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
'selectionParam eter'."

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 1312
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
2434
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 this app: =============================== static void Main(string args) { if (args.Length > 0) Console.SetIn(new StreamReader(args)); //executes if I don't use the "<", ">" redirection syntax when invoking XmlTextReader xmlin = new...
0
1129
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 occurred at file:///c:/inetpub/wwwroot/LakisService/books.xml, (2, 2).") private void Button2_Click(object sender, System.EventArgs e) { XmlTextReader r = new XmlTextReader(Server.MapPath("books.xml")); XmlSchema xs = new XmlSchema();
3
1192
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 'urn:books:catalog' element is not declared. An error occurred at file:///c:/inetpub/wwwroot/LakisService/books.xml, (2, 2).") private void Button2_Click(object sender, System.EventArgs e) { XmlTextReader r = new...
4
2607
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: Inner exception of type System.InvalidOperationException has occurred : The operation is not valid due to the current state of the object. [stack trace = at System.Xml.XmlValidatingReader.set_ValidationType(ValidationType
2
1812
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. The powers that be have determined that this is acceptable. I am looking for the best way to continue to validate my documents against my schema, but ignore any errors dealing with extra elements. My first thought is to use a...
5
1841
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 application is executed on the IIS server itself. However, I note that with the following
0
1113
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 schema specifies that it can only be 20 characters long, the Validator will create the error: "The 'LastName' element has an invalid value according to its data type. An error occurred at , (1, 148)." (Because I'm building the Xml file in...
1
3975
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 : Validation error: The element 'http://xmlns.somewhere.com/something:rDetail' cannot contain text. Expected 'http://xmlns.somewhere.com/something:AList'. An error occurred at , (1, 533). ----------
1
2586
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 : Validation error: The element 'http://xmlns.somewhere.com/something:rDetail' cannot contain text. Expected 'http://xmlns.somewhere.com/something:AList'. An error occurred at , (1, 533). ----------
0
9708
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9587
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10588
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10340
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10324
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7623
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5527
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4302
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3827
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.