Individual data set XML files were overwriting the overall XML file and each other.
Changed to write <prefix><datasetid>.xml