code: public static Transformer newTransformer(Source source, boolean omitXMLDeclaration, int indentAmount, String encoding) throws TransformerConfigurationException{
          TransformerFactory factory = TransformerFactory.newInstance();
          Transformer transformer = source!=null ? factory.newTransformer(source) : factory.newTransformer();
          return setOutputProperties(transformer, omitXMLDeclaration, indentAmount, encoding);
      }
docs: Creates Transformer
  
  @param source                source of xsl document, use null for identity transformer
  @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