void () { final XmlFile file = (XmlFile)createFile("file.xml", """ <?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd"> <a> <child> <child/> </child> </a>"""); final DomFileElementImpl<MyElement> fileElement = getDomManager().getFileElement(file, MyElement.class, "a"); myCallRegistry.clear(); final MyElement rootElement = fileElement.getRootElement(); final MyElement oldLeaf = rootElement.getChild().getChild(); final XmlTag oldLeafTag = oldLeaf.getXmlTag(); WriteCommandAction.runWriteCommandAction(getProject(), () -> { file.getDocument().getProlog().delete(); final XmlTag tag = file.getDocument().getRootTag(); tag.setAttribute("xmlns", "something"); tag.setAttribute("xmlns:xsi", "something"); }); assertTrue(oldLeafTag.isValid()); putExpected(new DomEvent(fileElement, false)); putExpected(new DomEvent(rootElement, false)); putExpected(new DomEvent(rootElement, false)); assertResultsAndClear(); assertEquals(fileElement.getRootElement(), rootElement); assertTrue(rootElement.isValid()); assertTrue(rootElement.getChild().isValid()); assertTrue(rootElement.getChild().getXmlTag().isValid()); assertTrue(rootElement.getChild().getChild().getXmlTag().isValid()); }