Browse Source

Fix off by one line and column numbers when validating xml.

pull/15/head
mrward 15 years ago
parent
commit
c6e8e72a64
  1. 24
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlView.cs

24
src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlView.cs

@ -145,7 +145,7 @@ namespace ICSharpCode.XmlEditor
Document.LoadXml(editor.Document.Text); Document.LoadXml(editor.Document.Text);
return true; return true;
} catch (XmlException ex) { } catch (XmlException ex) {
AddTask(editor.FileName, ex.Message, ex.LinePosition - 1, ex.LineNumber - 1, TaskType.Error); AddTask(editor.FileName, ex.Message, ex.LinePosition, ex.LineNumber, TaskType.Error);
} catch (WebException ex) { } catch (WebException ex) {
AddTask(editor.FileName, ex.Message, 0, 0, TaskType.Error); AddTask(editor.FileName, ex.Message, 0, 0, TaskType.Error);
} }
@ -347,7 +347,7 @@ namespace ICSharpCode.XmlEditor
settings.Schemas.Add(schemaData.Schema); settings.Schemas.Add(schemaData.Schema);
} }
} catch (XmlSchemaException ex) { } catch (XmlSchemaException ex) {
DisplayValidationError(schemaData.FileName, ex.Message, ex.LinePosition - 1, ex.LineNumber - 1); DisplayValidationError(schemaData.FileName, ex.Message, ex.LinePosition, ex.LineNumber);
ShowValidationFailedMessage(); ShowValidationFailedMessage();
ShowErrorList(); ShowErrorList();
return false; return false;
@ -360,9 +360,9 @@ namespace ICSharpCode.XmlEditor
return true; return true;
} catch (XmlSchemaException ex) { } catch (XmlSchemaException ex) {
DisplayValidationError(File.FileName, ex.Message, ex.LinePosition - 1, ex.LineNumber - 1); DisplayValidationError(File.FileName, ex.Message, ex.LinePosition, ex.LineNumber);
} catch (XmlException ex) { } catch (XmlException ex) {
DisplayValidationError(File.FileName, ex.Message, ex.LinePosition - 1, ex.LineNumber - 1); DisplayValidationError(File.FileName, ex.Message, ex.LinePosition, ex.LineNumber);
} }
ShowValidationFailedMessage(); ShowValidationFailedMessage();
ShowErrorList(); ShowErrorList();
@ -392,9 +392,9 @@ namespace ICSharpCode.XmlEditor
schemaSet.Compile(); schemaSet.Compile();
} }
} catch (XmlSchemaException ex) { } catch (XmlSchemaException ex) {
DisplayValidationError(File.FileName, ex.Message, ex.LinePosition - 1, ex.LineNumber - 1); DisplayValidationError(File.FileName, ex.Message, ex.LinePosition, ex.LineNumber);
} catch (XmlException ex) { } catch (XmlException ex) {
DisplayValidationError(File.FileName, ex.Message, ex.LinePosition - 1, ex.LineNumber - 1); DisplayValidationError(File.FileName, ex.Message, ex.LinePosition, ex.LineNumber);
} finally { } finally {
xmlReader.Close(); xmlReader.Close();
} }
@ -424,9 +424,9 @@ namespace ICSharpCode.XmlEditor
void SchemaValidation(object source, ValidationEventArgs e) void SchemaValidation(object source, ValidationEventArgs e)
{ {
if (e.Severity == XmlSeverityType.Error) { if (e.Severity == XmlSeverityType.Error) {
DisplayValidationError(File.FileName, e.Message, e.Exception.LinePosition - 1, e.Exception.LineNumber - 1); DisplayValidationError(File.FileName, e.Message, e.Exception.LinePosition, e.Exception.LineNumber);
} else { } else {
DisplayValidationWarning(File.FileName, e.Message, e.Exception.LinePosition - 1, e.Exception.LineNumber - 1); DisplayValidationWarning(File.FileName, e.Message, e.Exception.LinePosition, e.Exception.LineNumber);
} }
} }
@ -458,7 +458,7 @@ namespace ICSharpCode.XmlEditor
string transformedXml = Transform(editor.Document.Text, xsl); string transformedXml = Transform(editor.Document.Text, xsl);
ShowTransformOutput(transformedXml); ShowTransformOutput(transformedXml);
} catch (XsltException ex) { } catch (XsltException ex) {
AddTask(GetFileNameFromInnerException(ex, StylesheetFileName), GetInnerExceptionErrorMessage(ex), ex.LineNumber - 1, ex.LinePosition - 1, TaskType.Error); AddTask(GetFileNameFromInnerException(ex, StylesheetFileName), GetInnerExceptionErrorMessage(ex), ex.LineNumber, ex.LinePosition, TaskType.Error);
} }
} }
} }
@ -525,11 +525,11 @@ namespace ICSharpCode.XmlEditor
return true; return true;
} catch(XsltCompileException ex) { } catch(XsltCompileException ex) {
AddTask(StylesheetFileName, GetInnerExceptionErrorMessage(ex), ex.LineNumber - 1, ex.LinePosition - 1, TaskType.Error); AddTask(StylesheetFileName, GetInnerExceptionErrorMessage(ex), ex.LineNumber, ex.LinePosition, TaskType.Error);
} catch(XsltException ex) { } catch(XsltException ex) {
AddTask(StylesheetFileName, ex.Message, ex.LinePosition - 1, ex.LineNumber - 1, TaskType.Error); AddTask(StylesheetFileName, ex.Message, ex.LinePosition, ex.LineNumber, TaskType.Error);
} catch(XmlException ex) { } catch(XmlException ex) {
AddTask(StylesheetFileName, ex.Message, ex.LinePosition - 1, ex.LineNumber - 1, TaskType.Error); AddTask(StylesheetFileName, ex.Message, ex.LinePosition, ex.LineNumber, TaskType.Error);
} }
return false; return false;

Loading…
Cancel
Save