XMLStreamWriter writer = new SimpleXMLStreamWriter(result, false);
writer.setDefaultNamespace("http://foo");
writer.writeStartDocument();
writer.writeStartElement("alice");
writer.writeEmptyElement("bar", "bob", "http://bar");
writer.writeNamespace("bar", "http://bar");
writer.writeAttribute("jane", "dolly");
writer.writeCharacters("hello");
writer.writeEndElement();
writer.writeEndDocument();
writer.close();