code: public static void toWriter(Node node, Writer writer, Map<String, String> outputProperties) throws TransformerException {
  		try {
  			Transformer transformer = TransformerFactory.newInstance().newTransformer();
  			for (Map.Entry<String, String> property : outputProperties.entrySet()) {
  				try {
  					transformer.setOutputProperty(property.getKey(), property.getValue());
  				} catch (IllegalArgumentException e) {
  					//ignore invalid output properties
  				}
  			}
  
  			DOMSource source = new DOMSource(node);
  			StreamResult result = new StreamResult(writer);
  			transformer.transform(source, result);
  		} catch (TransformerConfigurationException e) {
  			//no complex configurations
  		} catch (TransformerFactoryConfigurationError e) {
  			//no complex configurations
  		}
  	}
docs: Writes an XML node to a writer.
  @param node the XML node
  @param writer the writer
  @param outputProperties the output properties
  @throws TransformerException if there's a problem writing to the writer