final Attribute[] attributes = element.unsafeGetAttributes();
final int attributesLen = element.numAttributes();
for (int i = 0; i < attributesLen; i++) {
final Attribute attribute = attributes[i];
boolean writeAttribute = true;
if (attribute.getNormalizedName().startsWith("xmlns:")) {
// xmlns attributes related to thymeleaf-managed prefixes (prefixes assigned to any of the
// dialects configured at the template engine) are always removed.
final String xmlnsPrefix = attribute.getNormalizedName().substring("xmlns:".length());
if (configuration.isPrefixManaged(xmlnsPrefix)) {
writeAttribute = false;
}
}
if (writeAttribute) {
writer.write(' ');
writer.write(attribute.getOriginalName());
final String attrValue = attribute.getEscapedValue();
if (!(attrValue == null && attribute.isOnlyName())) {
writer.write('=');
writer.write('\"');
if (attrValue != null) {
writer.write(attrValue);
}