try {
builder = factory.newDocumentBuilder();
} catch (ParserConfigurationException e) {
throw new JRException(e);
}
DOMImplementation impl = builder.getDOMImplementation();
Set<String> nsSet = xmlNamespaceMap.keySet();
Iterator<String> it = nsSet.iterator();
String prefix = it.next();
Document namespaceHolder = impl.createDocument(xmlNamespaceMap.get(prefix), prefix + ":namespaceMapping", null);
namespaceElement = namespaceHolder.getDocumentElement();
while (it.hasNext()) {
prefix = it.next();
namespaceElement.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:" + prefix, xmlNamespaceMap.get(prefix));