The following reader in .NET 2.0 does have line numbers.
static void Validate() {
XmlDocument doc = new XmlDocument();
XmlReaderSettings settings = new XmlReaderSettings();
settings.Schemas.Add(null, "test.xsd");
settings.ValidationType = ValidationType.Schema;
settings.ValidationEventHandler += new ValidationEventHandler(settings_ValidationEventHan dler);
XmlReader reader = XmlReader.Create("test.xml", settings);
while (reader.Read()) {
IXmlLineInfo li = (IXmlLineInfo)reader;
Console.WriteLine(li.LineNumber + "," + li.LinePosition + ": " + reader.NodeType.ToString() + " " + reader.Name);
}
return;
}
If you want line numbers in your schema use XmlSchema.Read passing in a Stream, TextReader or XmlReader but not an XmlNodeReader.
"Buddy Ackerman" <bu**********@buddyackerman.com> wrote in message news:eh**************@TK2MSFTNGP10.phx.gbl...
After doing some more searching I found the XmlSchemaException class. It
has a LineNumber and a LinePosition property. I thought my problems were
solved. Not so. Those properties alwasy appear to be zero. So I'm still
stuck.
"Buddy Ackerman" <bu**********@buddyackerman.com> wrote in message
news:ui**************@TK2MSFTNGP15.phx.gbl... In .NET 1.x the validating reader used an XmlTextReader which had
LineNumber and LinePosition properties so you could report where the validation took
place. In 2.0 the XmlReader is a validating reader but has no line number
or position properties so how can you tell where the error occured?
--Buddy