Don't assume that len(file extension suffix of mesh filename) is 3.

That's true for .xml, but not true for .xdmf.