Xmlvalidatingreader schematype property
for example: consider the XSD: while reading the document you can access the facets on the element like: while (vr. Hope this helps, Zafar "Matt" I take this one step further and get the Facet information for an invalid Xml element?Read()) if you are using the new validating Xml Reaer (in Visual Studio 2005 beta1) then the same property can be accessed via reader. I have my own validation event handler and I get the overall message about the problem but I need to report on what exactly the problem is. As for an Xml Node instance the reader is a pull based mechanism to read through an XML document, it doesn't create Xml Node instances at all, if you need them you would need to create them yourself which is obviously more work then just storing the node name of the parent element. I looked for a way to tell the user what XSD type the node in error is declared as, but to no avail.Surely that would be helpful information when debugging. Close(); "Martin Honnen" wrote: That would be very ugly code because there are parent nodes that have child nodes with the same name.Seems that when an error such as a value out of range occurs, by the time the validation error routine is called it is on the end element of whatever node the error occured in. Schema; public class Test2005032601 That then gives information alike Type should be System. I have now tried to store the Schema Type property the reader exposes and access it in the validation event handler as follows: using System; using System.
I have my own validation event handler and I get the overall message about the problem but I need to report on what exactly the problem is. Xml-Spy gives you the exact information but I need to do it programmatically with customers data and report errors. Thanks, Matt I know how to use the Xml Reader to validate XML against a Schema but how do I take this one step further and get the Facet information for an invalid Xml element? FAQTs.com/ There is a Schema Type property on the Xml Validating Reader which exposes the XSD schema information of the SOM Element or Attribute currently being validated in the XML Document.I think it would be worth while for the developer to have more control over the validation and to have access to the underlying XSD elements when an error occurs. string current Node Name; int prev Depth = 0; parent Node Name = current Node Name = reader. I would have to look for the names of the parent nodes and keep track of my own position within the reader.Since the format of this XML could change, I don't want to put anything related to node names or strings in the code. Datatype_NCName do not seem to be part of the public classes the .Since the format of this XML could change, I don't want to put anything related to node names or strings in the code.
Here is an example of what I'm talking about: so you can as I suggested and showed you in the previous post at any time read out the current node type the reader is positioned on with the Node Type property, read out the current node name with the Name property.
I know my data is good because, when I load the schema into the Schemas property of the Validating Reader instead of trying to use the Xml Resolver, all seems to work properly.