I think you've hit upon the reason for this XSLT operation:
http://www.w3schools.com/xsl/el_namespace-alias.asp
which leaves your mangled namespaces intact until output is generated, when the namespace transformation is done.