There are a couple of work arounds:
1. You can add the type attirbute without the namespace and then do a .replace(' type=', ' xsi:type='));