Make transformXml() more robust