String attributeName, String attributeValue) throws XMLStreamException {
Attribute newAttribute = xmlEventFactory.createAttribute(attributeName, attributeValue);
Set attributes = new HashSet();
attributes.add(newAttribute);
EndElement oldEvent = event.asEndElement();
StartElement newStartEvent = xmlEventFactory.createStartElement(new QName(elementName),
attributes.iterator(), oldEvent.getNamespaces());
writer.add(newStartEvent);
return xmlEventFactory.createEndElement(newStartEvent.getName(), newStartEvent.getNamespaces());
}