@Test public void testXHTMLWithMisleading() throws Exception { String test = "<?xml version=\"1.0\" ?>" + "<!DOCTYPE html PUBLIC \"- "<html xmlns=\"http: "<head>\n" + "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />\n" + "<title>title</title></head><body>body</body></html>"; Metadata metadata = new Metadata(); AUTO_DETECT_PARSER.parse( new ByteArrayInputStream(test.getBytes(UTF_8)), new BodyContentHandler(), metadata, new ParseContext()); assertEquals("text/html; charset=iso-8859-1", metadata.get(TikaCoreProperties.CONTENT_TYPE_HINT)); assertEquals("application/xhtml+xml; charset=ISO-8859-1", metadata.get(Metadata.CONTENT_TYPE)); test = "<?xml version=\"1.0\" ?>" + "<!DOCTYPE html PUBLIC \"- "<html xmlns=\"http: "<head>\n" + "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-NUMBER_SEVEN\" />\n" + "<title>title</title></head><body>body</body></html>"; metadata = new Metadata(); AUTO_DETECT_PARSER.parse( new ByteArrayInputStream(test.getBytes(UTF_8)), new BodyContentHandler(), metadata, new ParseContext()); assertEquals("text/html; charset=iso-NUMBER_SEVEN", metadata.get(TikaCoreProperties.CONTENT_TYPE_HINT)); assertEquals("application/xhtml+xml; charset=ISO-8859-1", metadata.get(Metadata.CONTENT_TYPE)); }
public void parse( InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException { TemporaryResources tmp = null; try { if (!TikaInputStream.isTikaInputStream(stream)) { tmp = new TemporaryResources(); stream = TikaInputStream.get(stream, tmp); } parseImpl(stream, handler, metadata, context); } finally { if (tmp != null) { tmp.close(); } } }
HtmlParser extends AbstractEncodingDetectorParser { public void parse( InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException { TemporaryResources tmp = null; try { if (!TikaInputStream.isTikaInputStream(stream)) { tmp = new TemporaryResources(); stream = TikaInputStream.get(stream, tmp); } parseImpl(stream, handler, metadata, context); } finally { if (tmp != null) { tmp.close(); } } } }
HtmlParser extends AbstractEncodingDetectorParser { public void parse( InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException { TemporaryResources tmp = null; try { if (!TikaInputStream.isTikaInputStream(stream)) { tmp = new TemporaryResources(); stream = TikaInputStream.get(stream, tmp); } parseImpl(stream, handler, metadata, context); } finally { if (tmp != null) { tmp.close(); } } } HtmlParser();  HtmlParser(EncodingDetector encodingDetector); }
HtmlParser extends AbstractEncodingDetectorParser { public void parse( InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException { TemporaryResources tmp = null; try { if (!TikaInputStream.isTikaInputStream(stream)) { tmp = new TemporaryResources(); stream = TikaInputStream.get(stream, tmp); } parseImpl(stream, handler, metadata, context); } finally { if (tmp != null) { tmp.close(); } } } HtmlParser();  HtmlParser(EncodingDetector encodingDetector); Set<MediaType> getSupportedTypes(ParseContext context); void parse(
            InputStream stream, ContentHandler handler,
            Metadata metadata, ParseContext context); String mapSafeAttribute(String elementName, String attributeName); @Field void setExtractScripts(boolean extractScripts); boolean getExtractScripts(); }
HtmlParser extends AbstractEncodingDetectorParser { public void parse( InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException { TemporaryResources tmp = null; try { if (!TikaInputStream.isTikaInputStream(stream)) { tmp = new TemporaryResources(); stream = TikaInputStream.get(stream, tmp); } parseImpl(stream, handler, metadata, context); } finally { if (tmp != null) { tmp.close(); } } } HtmlParser();  HtmlParser(EncodingDetector encodingDetector); Set<MediaType> getSupportedTypes(ParseContext context); void parse(
            InputStream stream, ContentHandler handler,
            Metadata metadata, ParseContext context); String mapSafeAttribute(String elementName, String attributeName); @Field void setExtractScripts(boolean extractScripts); boolean getExtractScripts();  }