visitElement method
Visit an XmlElement node.
Implementation
@override
void visitElement(XmlElement node) {
buffer.write(XmlToken.openElement);
node.name.accept(this);
writeAttributes(node);
if (node.children.isEmpty && node.isSelfClosing) {
if (spaceBeforeSelfClose != null && spaceBeforeSelfClose!(node)) {
buffer.write(' ');
}
buffer.write(XmlToken.closeEndElement);
} else {
buffer.write(XmlToken.closeElement);
if (node.children.isNotEmpty) {
if (pretty) {
if (preserveWhitespace != null && preserveWhitespace!(node)) {
pretty = false;
writeIterable(node.children);
pretty = true;
} else if (node.children.every((each) => each is XmlText)) {
writeIterable(normalizeText(node.children));
} else {
level++;
buffer.write(newLine);
buffer.write(indent * level);
writeIterable(normalizeText(node.children), newLine + indent * level);
level--;
buffer.write(newLine);
buffer.write(indent * level);
}
} else {
writeIterable(node.children);
}
}
buffer.write(XmlToken.openEndElement);
node.name.accept(this);
buffer.write(XmlToken.closeElement);
}
}