Improve support for attribute transfering

Improved replacement function to handle quoted and unquoted
attributes, as well as hifen separated attribute names.