code: public static Transformer setOutputProperties(Transformer transformer, boolean omitXMLDeclaration, int indentAmount, String encoding){
          transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, omitXMLDeclaration ? "yes" : "no");
  
          // indentation
          if(indentAmount>0){
              transformer.setOutputProperty(OutputKeys.INDENT, "yes");
              transformer.setOutputProperty(OUTPUT_KEY_INDENT_AMOUT, String.valueOf(indentAmount));
          }
  
          if(!StringUtil.isWhitespace(encoding))
              transformer.setOutputProperty(OutputKeys.ENCODING, encoding.trim());
  
          return transformer;
      }
docs: to set various output properties on given transformer.
  
  @param transformer           transformer on which properties are set
  @param omitXMLDeclaration    omit xml declaration or not
  @param indentAmount          the number fo spaces used for indentation.
  use <=0, in case you dont want indentation
  @param encoding              required encoding. use null to don't set any encoding
  
  @return the same transformer which is passed as argument