}
private static void writeStartElementEvent(XMLEvent event, XMLStreamWriter writer)
throws XMLStreamException {
StartElement start = event.asStartElement();
QName name = start.getName();
String nsURI = name.getNamespaceURI();
String localName = name.getLocalPart();
String prefix = name.getPrefix();
if (prefix != null) {
writer.writeStartElement(prefix, localName, nsURI);
} else if (nsURI != null) {
writer.writeStartElement(localName, nsURI);
} else {
writer.writeStartElement(localName);
}
Iterator<XMLEvent> it = CastUtils.cast(start.getNamespaces());
while (it != null && it.hasNext()) {
writeEvent(it.next(), writer);
}
it = CastUtils.cast(start.getAttributes());
while (it != null && it.hasNext()) {
writeAttributeEvent(it.next(), writer);
}
}