This project has moved. For the latest updates, please go here.

XML Schema error are not detected and reported


Warnings and errors (if any) from the Xml parser should be logged and be shown to the user,

Addition in XmlEntriesProvider.GetEntries(...)
settings.ValidationEventHandler += settings_ValidationEventHandler;
Additional function and field in XmlEntriesProvider
    /// <summary>
    /// List of messages encountered durring XSD based parser execution
    /// </summary>
    private System.Collections.Generic.List<string> mXmlParserMsg = new List<string>();

    /// <summary>
    /// method is executed when XML validation fails and warnings or errors need to be logged.
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void settings_ValidationEventHandler(object sender, System.Xml.Schema.ValidationEventArgs args)
      switch (args.Severity)
        case XmlSeverityType.Warning:
          this.mXmlParserMsg.Add(string.Format("Warning: Line: {0}, Position: {1} {2}",
                                           args.Exception.LineNumber, args.Exception.LinePosition, args.Exception.Message));

        case XmlSeverityType.Error:
          this.mXmlParserMsg.Add(string.Format("Error: Line: {0}, Position: {1} {2}",
                                           args.Exception.LineNumber, args.Exception.LinePosition, args.Exception.Message));

          this.mXmlParserMsg.Add(string.Format("Unhandled Severity of type: {0} {1}", args.Severity.ToString(), args.Message));
Warnings like this should be passed on to the caller of the loader process. This requires an extension of the task starting (LogFileLoader.cs line 116) like this:
            Task taskToProcess = Task.Factory.StartNew<ObservableCollection<Message>>(stateObj =>
we then need to create the corresponding collection in the task:
          ObservableCollection<Message> processResults = new ObservableCollection<Message>();
The collection should then be passed back on to the calling task and be returned at the end of the task:
      return processResults;
I wonder if you get warnings in this collection when you try to import a log file with special characters as you reported in a different issue?


gwentreb wrote Jun 24, 2013 at 9:28 AM

This collection is always empty when loading files because the exception is catched inside the loadFiles function and it's not throwed but displayed on the ui in a messagebox. I'm gonna work on this :)

dirkster wrote Jun 24, 2013 at 6:58 PM

Yes you are right - the collection is always empty - I remember this differently when used this code in another project. Maybe the XML parser is more relaxed here than when using a full blown XML Schema. I was able to add things like

<Dirkster>... (some log4 tag) ... </Dirkster>


<log4j:Dirkster> ... </log4j:Dirkster>

and got no error being reported. I was only able get an error when tag is not closed. But maybe this relaxed parsing is intended? Is it?