Ensure that prefixed attributes are properly namespaced when reparented

Fixes #869