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.
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.
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.
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
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.
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.
GUI error messages implemented in revision 5621.
All done as of revision 5642.
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.
This (warning before import invalid xml) was also part of the original feature request
Added dialog in revision 5653. Any feedback appreciated.
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.
what about when in 'plugin-mode', e.g. the batch-export plugin?
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?
Fixed in 28b0eba599
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.
Automatically closed -- issue fixed for 2 weeks with no activity.