Musicxml fixes

Fix for #17507 is incomplete, but does some improvement without any side effects. Will take more time to complete. I'd like the fix for #28341 to be merged a.s.a.p., it is easiest to merge everything in this branch.