List of usage examples for javax.xml.stream XMLStreamWriter setDefaultNamespace
public void setDefaultNamespace(String uri) throws XMLStreamException;
From source file:org.unitedinternet.cosmo.util.DomWriter.java
private static void writeElement(Element e, XMLStreamWriter writer) throws XMLStreamException { //if (log.isDebugEnabled()) //log.debug("Writing element " + e.getNodeName()); String local = e.getLocalName(); if (local == null) { local = e.getNodeName();//from w ww. j a v a 2s. co m } String ns = e.getNamespaceURI(); if (ns != null) { String prefix = e.getPrefix(); if (prefix != null) { writer.writeStartElement(prefix, local, ns); writer.writeNamespace(prefix, ns); } else { writer.setDefaultNamespace(ns); writer.writeStartElement(ns, local); writer.writeDefaultNamespace(ns); } } else { writer.writeStartElement(local); } NamedNodeMap attributes = e.getAttributes(); for (int i = 0; i < attributes.getLength(); i++) { writeAttribute((Attr) attributes.item(i), writer); } NodeList children = e.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { writeNode(children.item(i), writer); } writer.writeEndElement(); }