MusicXML - transposing instrument parts
If a MusicXML file includes a part for a transposing instrument not notated at "concert pitch" (sounding pitch), as for a player's part, the code must include a transpose element. That element must include a chromatic subelement, which gives (in semitones) the interval between the encoded note pitches and their sounding pitches. This is sufficient to allow the receiving program to play the part at the intended sounding pitch.
But if the receiving program wishes to offer the display of the received part at concert pitch, there can be a dilemma as to how any resulting accidentals are spelled.
To resolve this, MusicXML allows (and even encourages, but does not require) the including in the transpose element of a second subelement, diatonic. This, together with the value of chromatic, defines the "named interval" (e.g., "perfect fourth") that the originating notation program would have used to display this transposed part at concert pitch. The numerical base of the pitch name is one more than the value of diatonic. Thus, if diatonic is 4, the transposition interval is one of those with "fifth" in its name.
Which of the "fifths" (perfect fifth or augmented fifth) is meant is discerned from the value of chromatic. Thus if diatonic is 4, and chromatic is 7, the transposition interval is perfect fifth. if diatonic is 4, and chromatic is 8, the transposition interval is augmented fifth. Only certain combinations of the values of diatonic and chromatic are meaningful. If diatonic is 4, for chromatic, only values of 7 and 8 (as used in the example above) are meaningful. (There are only two named intervals with "fifth" in their name.)
For a MusicXML part that carries a transpose element with both diatonic and chromatic subelements, MuseScore in fact chooses the intended named interval to transpose the received part into concert pitch notation (when the Concert Pitch button is ON) as the originating program/scorist intended.
But if the element does not contain a diatonic subelement (which is perfectly legitimate under the MusicXML specification), MuseScore (perhaps understandably) treats the value of diatonic as zero. This means that MuseScore proceeds as if the intended interval for transposing the part to concert pitch is one with "unison" in its name. But that could only be correct if chromatic were 0 (no transposition, in which case we would need no transpose element) or 1 (if the named interval were augmented unison).
The result is that, of we ask MuseScore to show us this received transposed part at concert pitch, we may well have a "correct", but bizarre, transposition, perhaps full of double flats or sharps.
A better algorithm
It would be better if, when a received MusicXML file contains for a part a transpose element with a chromatic subelement but no diatonic subelement, MuseScore would treat the value of diatonic as one that was meaningful given the value of chromatic, probably the one that, with the value of chromatic, would imply a named interval of the "perfect", "major", or "minor" families. The exception would be for a chromatic value of 6 (a six semitone interval), for which there is no named interval of any of those qualities. There, an arbitrary choice would have to be made between inferring that the named interval were diminished fifth or augmented fourth.
Doing this would require a small lookup table working from the value of chromatic (or actually that value modulo 12, to deal with values of chromatic that were greater than an octave).