private static void prepareDocType ( final InputStream body , final Transformer transformer ) throws IOException { try { final String html = "html" ; final DocumentType doctype = RsPrettyXml . getDocType ( body ) ; if ( null != doctype ) { if ( null == doctype . getSystemId ( ) && null == doctype . getPublicId ( ) // @checkstyle MultipleStringLiteralsCheck (3 line) && html . equalsIgnoreCase ( doctype . getName ( ) ) ) { transformer . setOutputProperty ( OutputKeys . METHOD , html ) ; transformer . setOutputProperty ( OutputKeys . VERSION , "5.0" ) ; return ; } if ( null != doctype . getSystemId ( ) ) { transformer . setOutputProperty ( OutputKeys . DOCTYPE_SYSTEM , doctype . getSystemId ( ) ) ; } if ( null != doctype . getPublicId ( ) ) { transformer . setOutputProperty ( OutputKeys . DOCTYPE_PUBLIC , doctype . getPublicId ( ) ) ; } } } finally { body . reset ( ) ; } }
Parses body to get DOCTYPE and configure Transformer with proper method public id and system id .