I've never been deep into XSLT, but I kind of have the impression, that this would have solved the issue.