G
Guest
I have this code:
XmlDocument x = new XmlDocument();
x.Schemas.Add(
null //use the targetnamespace stored in the schema file
, ExtendedTreeViewSchema //URL of schema file.
);
x.LoadXml(XmlSource);
x.Validate(new ValidationEventHandler(Handler));
The event handler looks like this:
private static void Handler(object sender, ValidationEventArgs e)
{
if (e.Severity == XmlSeverityType.Error || e.Severity ==
XmlSeverityType.Warning)
System.Diagnostics.Trace.WriteLine(
String.Format("Line: {0}, Position: {1} \"{2}\"",
e.Exception.LineNumber, e.Exception.LinePosition,
e.Exception.Message));
}
In VS2005 IDE I can take an XML document and purposely invalidate a couple
of lines according to the schema specification. Having done so, I see the
following messages in the VS2005 IDE:
Warning 1 The 'columnValue' element is invalid - The value 'AUD'' is invalid
according to its datatype
VS also tells me this warning occurred on Line 31 at Column 30
Warning 2 The 'columnValue' element is invalid - The value 'CRC*'' is
invalid according to its datatype
VS also tells me that this warning occurred on Line 41 at column 31.
Both Warnings and Lines/Column numbers are what I expect based on the errors
I purposely made in the file.
When I run the code using the same XML file, I get the same messages but
the Line and Column numbers are always 0:
Line: 0, Position: 0 "The 'columnValue' element is invalid - The value
'AUD'' is invalid according to its datatype
Line: 0, Position: 0 "The 'columnValue' element is invalid - The value
'CRC*'' is invalid according to its datatype
What am I doing wrong?
XmlDocument x = new XmlDocument();
x.Schemas.Add(
null //use the targetnamespace stored in the schema file
, ExtendedTreeViewSchema //URL of schema file.
);
x.LoadXml(XmlSource);
x.Validate(new ValidationEventHandler(Handler));
The event handler looks like this:
private static void Handler(object sender, ValidationEventArgs e)
{
if (e.Severity == XmlSeverityType.Error || e.Severity ==
XmlSeverityType.Warning)
System.Diagnostics.Trace.WriteLine(
String.Format("Line: {0}, Position: {1} \"{2}\"",
e.Exception.LineNumber, e.Exception.LinePosition,
e.Exception.Message));
}
In VS2005 IDE I can take an XML document and purposely invalidate a couple
of lines according to the schema specification. Having done so, I see the
following messages in the VS2005 IDE:
Warning 1 The 'columnValue' element is invalid - The value 'AUD'' is invalid
according to its datatype
VS also tells me this warning occurred on Line 31 at Column 30
Warning 2 The 'columnValue' element is invalid - The value 'CRC*'' is
invalid according to its datatype
VS also tells me that this warning occurred on Line 41 at column 31.
Both Warnings and Lines/Column numbers are what I expect based on the errors
I purposely made in the file.
When I run the code using the same XML file, I get the same messages but
the Line and Column numbers are always 0:
Line: 0, Position: 0 "The 'columnValue' element is invalid - The value
'AUD'' is invalid according to its datatype
Line: 0, Position: 0 "The 'columnValue' element is invalid - The value
'CRC*'' is invalid according to its datatype
What am I doing wrong?