[MusicXML] Use MusicXML schema to validate files before import

• Feb 17, 2012 - 12:37
Type
Functional
Severity
S5 - Suggestion
Status
closed
Project

MusicXML provides a schema in XSD format and Qt support XML validation. It could be a good idea to add validation before import and warn the user that the file is not valid.

Any though?


Comments

Sounds like a good idea, but I will have to investigate.
Note: this should IMHO (also) work without Internet connection (using a local copy of the schema file), which probably implies we also need to include the XSD files in the MuseScore distribution. I assume this is allowed by Recordare/MakeMusic, but will have to make sure.

Am investigating. Given a schema file and an xml file, validation itself using Qt's QXmlSchemaValidator is easy, but I still need to work out a few details.

Initial implementation done in revision 5613.

Notes:
- uses the MusicXML 3.0 schema (which is compatible with the previous versions)
- implemented for uncompressed MusicXML only (compressed files will be done later)
- understandable GUI errror messages still missing (error reporting on the console only)
- also still TODO: make the MusicXML license end-user visible

In order to make the MusicXML license end-user visible, I intend to add a menu item (Help / About MusicXML)

Validation of compressed MusicXML files implemented in revision 5617.

Note performance: on my (admittedly not very new) PC, the validator processes about 100k of uncompressed MusicXML per second. For the typical Recordare sample files of one page, validation adds about one second overhead on import.

Title [MusicXML] Use MusicXML schema to validate files before import ? [MusicXML] Use MusicXML schema to validate files before import

GUI error messages implemented in revision 5621.

Great job ! well done.
One remark though. If I understand the implementation well, an unvalid file is know not imported at all. Unfortunatly there are a lot of unvalid files out there... Maybe we could warn users by saying the file is not valid and they can try to import at their own risk ? Finale seems to do that, giving you a bunch of warnings before you can open your file.

Yes, you are right on both counts:
- the current implementation refuses to load invalid files
- it is probably a good idea to throw a warning and ask the user if he wants to try anyway

Will see what I can do,

Regards, Leon.

I like it. I like the two steps process with the "more details" button.
Two things to take into account :
- if the user press No, there is a second dialog. We should probably decide if we want to deal with user feedback and the level of the import filter or one step higher.
- in command line (converter mode) we probably don't want dialog.

Yes, I also planned to disable the second dialog if the user selects "no", but am getting a bit too tired to do that now. Note that this implies passing a bit more information from the importer to the caller than is possible now. For the time being, at least we have both schema validation and the option to ignore the validation result.

When loading an invalid file which is specified on the command line ("mscore invalid_file"), there is even a third dialog (!), which I propose to remove too.

I am sorry, but as I never use the plugin framework, I wouldn't know. I don't have Qt script installed, so I am unable to easily test plugin behaviour myself.

The import code that shows the dialog currently does not check for batch mode, so I would expect to get a dialog for every invaild MusicXML file that is imported in batch mode. Feel free to verify what happens and to specify how to improve it if necessary.

Isn't the plugin interface always installed? You could try out the behavoir using the batch export plugin , selecting xml as input and mscz as output format.
Actualy I'm not even sure what the behavoir should be in this case, it is sort of interactive (as opposed to command line batch mode). I guess an additional dialog when importing lots of invalid XML files would be quite annoying, but would be usefull if there is only one invalid out of say 20. Maybe an additional check box 'don't ask again in this session' or some such might be good?

Today's commit adds details to the validation error dialog and removes the superfluous second dialog after the validation error dialog. The converter mode behavior is still unchanged, mostly because I still don't have a fail-safe solution. Ignoring validation errors on converter mode would probably just lead to crashes. For now, I consider this done.