Where is there a definitive MusicXML validator?

• Jun 9, 2015 - 14:19

This isn't really a feature request, but I keep getting tripped up by MusicXML files created by third-party apps (Sibelius, Finale, SharpEye, Neuratron) and indeed MusicXML files exported by MuseScore itself.

It would be great if someone who knows this field in detail could point us to a URL for a neutral MusicXML validator which can reliably validate MusicXML 1.0, 2.0 and 3.0. Is there such a service available?

Thanks!
Dan


Comments

It depends what you mean by "validator".

MusicXML 3.0 comes with a XSD schema. It defines the possible values of elements, which element can be added in other elements etc... MuseScore uses this schema to validate a MusicXML file when you open it. This schema is delivered by the MusicXML creators (see http://musicxml.org).

Once a MusicXML file is "valid" in term of schema validation, there is a second layer. A measure in 4/4 with a single quarter note, is that valid? Even when the schema validation says the file is OK, there could be many ways to encode a particular musical construction (for example a slur, or a full measure rest) and some software will export such a construction in a way, while others will do it another way. There is no validator for these behaviors and the MusicXML specification is fuzzy enough to make it impossible to create such a validator...

If you need more information about MusicXML, the best place is the MusicXML forum http://forums.makemusic.com/viewforum.php?f=12. Michael Good, the creator of MusicXML, will answer your questions there.

The instructions from http://web.archive.org/web/20210505231911/https://blog.karimratib.me/20… worked for me. I used the patch with the local files, changing the two lines each in musicxml.xsd and opus.xsd to read […] schemaLocation="xml.xsd" and xlink.xsd respectively:

$ fgrep xs:import Misc/Vendor/musicxml-3.1/schema/musicxml.xsd
        <xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="xml.xsd"/>
        <xs:import namespace="http://www.w3.org/1999/xlink" schemaLocation="xlink.xsd"/>

It works as advertised:

$ xmllint --schema ~/Misc/Vendor/musicxml-3.1/schema/musicxml.xsd Silcher\ --\ Loreley.xml --noout
Silcher -- Loreley.xml validates

Since I prefer xmlstarlet over xmllint, let’s do this:

$ xmlstarlet val -e -d ~/Misc/Vendor/musicxml-3.1/schema/partwise.dtd Silcher\ --\ Loreley.xml
Attempt to load network entity http://www.musicxml.org/dtds/partwise.dtd
Silcher -- Loreley.xml - valid

With xmlstarlet the DOCTYPE is not ignored, so you have to pass the matching one (partwise.dtd or timewise.dtd) instead of just musicxml.dtd; it says “Attempt to load network” but actually doesn’t.

Enjoy!

Do you still have an unanswered question? Please log in first to post your question.