XMLStreamWriter createXMLStreamWriter(boolean repairNamespaces) throws XMLStreamException {
final StringWriter writer = new StringWriter();
if (jdkStreamWriter) {
XMLOutputFactory factory = XMLOutputFactory.newFactory();
factory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, repairNamespaces);
return new StreamWriterDelegate(factory.createXMLStreamWriter(writer)) {
@Override
public String toString() {
return writer.toString();
}
};