String (XmlDocument doc, boolean full) { final Map<String, List<String>> tags = new LinkedHashMap<>(); final Map<String, List<MyAttributeInfo>> attributes = new LinkedHashMap<>(); final XmlTag rootTag = doc.getRootTag(); computeTag(rootTag, tags, attributes, full); // For supporting not well-formed XML for (PsiElement element = rootTag != null ? rootTag.getNextSibling() : null; element != null; element = element.getNextSibling()) { if (element instanceof XmlTag) { computeTag((XmlTag)element, tags, attributes, full); } } final StringBuilder buffer = new StringBuilder(); for (final String tagName : tags.keySet()) { buffer.append(generateElementDTD(tagName, tags.get(tagName), attributes.get(tagName))); } return buffer.toString(); }