private Document parse(final String data,DocumentBuilder docBuilder){
  if (docBuilder == null || data == null) {
    return null;
  }
  Document document=null;
  try {
    StringBuilder buf=new StringBuilder(1024);
    if (!data.startsWith("<?xml")) {
      buf.append(BEGIN_PART);
    }
    buf.append(data);
    if (!data.endsWith(END_PART)) {
      buf.append(END_PART);
    }
    InputSource inputSource=new InputSource(new StringReader(buf.toString()));
    document=docBuilder.parse(inputSource);
  }
 catch (  Exception e) {
    LOGGER.warn("Problem with creating document: " + e.getMessage());
  }
  return document;
}

private Document parse ( final String data , DocumentBuilder docBuilder ) { if ( docBuilder == null || data == null ) { return null ; } Document document = null ; try { StringBuilder buf = new StringBuilder ( 1024 ) ; if ( ! data . startsWith ( "<?xml" ) ) { buf . append ( BEGIN_PART ) ; } buf . append ( data ) ; if ( ! data . endsWith ( END_PART ) ) { buf . append ( END_PART ) ; } InputSource inputSource = new InputSource ( new StringReader ( buf . toString ( ) ) ) ; document = docBuilder . parse ( inputSource ) ; } catch ( Exception e ) { LOGGER . warn ( "Problem with creating document: " + e . getMessage ( ) ) ; } return document ; }
converts the loggingevent data in xml string format into an actual xml document class instance .
