Use setAttributes and remove qname checking

DOM will throw an exception if you specify invalid qualified name.
No need to double check it again.