private void processStartTag(StartTag tag) { if ("<".equals(tag.getTagType().getStartDelimiter())) { Element e = document.createElement(tag.getNameSegment().toString()); stack.push(new Level(tag)); writer.write("<"); writer.write(tag.getNameSegment().toString()); Attributes attributes = tag.getAttributes(); if (!attributes.isEmpty()) { for (Attribute attribute : attributes) { processAttribute(attribute); } } if (tag.toString().trim().endsWith("/>") || tag.isEmptyElementTag()) { stack.pop(); writer.write("/>"); } else { writer.write(">"); } } else { writer.write(tag.toString()); } }