Java tutorial
//package com.java2s; import java.net.URI; import java.util.Map.Entry; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamWriter; public class Main { private static void writeNamespaceDeclarations(XMLStreamWriter writer, Iterable<Entry<URI, String>> prefixes) throws XMLStreamException { for (Entry<URI, String> e : prefixes) { final String ns = e.getKey().toString(); final String p = e.getValue(); writer.writeNamespace(p, ns); } } }