Metadata metadata = new Metadata();
//set the already parsed contentType
metadata.set(Metadata.CONTENT_TYPE, mtas.mediaType.toString());
final StringWriter writer = new StringWriter();
final ContentHandler textHandler = new BodyContentHandler( //only the Body
new PlainTextHandler(writer, false,skipLinebreaks)); //skip ignoreable
final ToXMLContentHandler xhtmlHandler;
final ContentHandler mainHandler;
if(!plainMediaType.equals(XHTML)){ //do not parse XHTML from XHTML
xhtmlHandler = new ToXMLContentHandler();
mainHandler = new MultiHandler(textHandler,xhtmlHandler);