For Programmers: Free Programming Magazines  


Home > Archive > ASP .NET > June 2007 > XSD validation in VB .NET









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author XSD validation in VB .NET
Mic

2007-06-28, 7:11 pm

Hi,

I'm doing validation of a xml file with a xsd schema and it works
fine.

I get validation errors in the form:

=ABMessage:{0} The 'NAM' attribute has an invalid value according to its
data type. An error occurred at file:///A:/myfile.xml, (526, 12).=BB

I can isolate line and column using the args.Exception.LineNumber and
args.Exception.LinePosition properties.

Unfortunately, there is no property to retrieve the element or
attribute name. I have to make a search in the Message string to get
it. And there is no apparent way of getting the value in fault.

Identifying errors is fine but then I need to correct them. I can do
corrections manually using the line and column positions but it's not
very practical for large files.

How can I link the informations given by the XmlValidatingReader to a
dataset or anything that can help me make modifications to correct the
errors ?

thanks

Martin Honnen

2007-06-28, 7:11 pm

Mic wrote:

> Unfortunately, there is no property to retrieve the element or
> attribute name.


There is, cast the sender argument of your ValidationEventHandler to an
XmlReader and read out the Name property of the XmlReader.



> How can I link the informations given by the XmlValidatingReader to a
> dataset or anything that can help me make modifications to correct the
> errors ?


Load into a System.Xml.XmlDocument, that way you get type annotations
(e.g.
<http://msdn2.microsoft.com/en-us/li...SchemaInfo.aspx> )
on the nodes in the XML document and you can manipulate and revalidate
as needed.


--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com