void () { final MyElement element = createElement("<a xmlns=\"foo\" xmlns:bar=\"bar\"/>", MyElement.class); registerNamespacePolicies(element); final MyElement element2 = createElement("<f:a xmlns:f=\"foo1\" xmlns:b=\"bar1\" xmlns=\"foo1\">" + "<foo-child/>" + "<b:bar-child/>" + "<f:some-child/>" + "<f:foo-element attr-2=\"239\" attr=\"42\"/>" + "<f:foo-element/>" + "<f:bool/>" + "<sys:aaa/>" + "</f:a>", MyElement.class); registerNamespacePolicies(element2, "foo1", "bar1"); WriteCommandAction.runWriteCommandAction(getProject(), () -> element.copyFrom(element2)); assertEquals("<a xmlns=\"foo\" xmlns:bar=\"bar\">" + "<bar:bar-child/>" + "<bool/>" + "<foo-child/>" + "<some-child/>" + "<sys:aaa/>" + "<foo-element attr=\"42\" attr-2=\"239\"/>" + "<foo-element/>" + "</a>", element.getXmlTag().getText()); }