XES 2.0 and switch to use Nokogiri #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I have a requirement to produce some XES files for a project that I am working on and so found my way to this gem.
The first thing that struck me was that REXML produces XML that uses single-quotes for attributes whereas I think most of us would regard double-quotes as more common. Potentially this wouldn't have bothered me until I read about the fact that classifier keys can be grouped using single-quotes - which obviously won't work if the attributes are using single-quotes. I looked for ways to make REXML use double-quotes and although I had limited success I simply couldn't get it to work for the whole file.
So, I decided to switch out the XML implementation from REXML (which I haven't used) to Nokogiri (which I have) which uses double-quotes by default. I think Nokogiri is more common these days and it is certainly a lot faster. As it turned out, this was pretty straight forward in the end - the only significant wrinkle being that a Document is required to create a new Element requiring an additional parameter to most of the format methods - thankfully this wasn't required for the XES::Document format method so this is largely invisible to the user. The result is that there is only one change in the external interface to ruby-xes in the way that the resulting XML is written out to file (you can see this clearly in the example program).
Whilst doing this it seemed to make sense to upgrade everything to XES 2.0 at the same time. This required me to implement list and container attributes - which were really very straight forward in the end.
Doubtless my changes could perhaps have been written more elegantly but I have tried to stay true to the original design - and on the whole I think the result isn't bad. I did have to change some of the tests but thankfully there weren't too many. I also added some new tests for the new list and container attributes.
As a relative newcomer to Ruby I found the documentation too terse so I have added an example program that reads a CSV logfile and formats it as XES. This is quite possibly the weakest aspect of my contribution - not least because I suspect that there are many nuances of XES that I have yet to fully grasp. But hopefully it is a better starting point for newcomers.
Joe