Package org.apache.tika.parser.html
Interface HtmlMapper
- All Known Implementing Classes:
DefaultHtmlMapper,IdentityHtmlMapper
public interface HtmlMapper
HTML mapper used to make incoming HTML documents easier to handle by
Tika clients. The
looks up an optional HTML mapper from
the parse context and uses it to map parsed HTML to "safe" XHTML. A client
that wants to customize this mapping can place a custom HtmlMapper instance
into the parse context.
invalid reference
HtmlParser
- Since:
- Apache Tika 0.6
-
Method Summary
Modifier and TypeMethodDescriptionbooleanisDiscardElement(String name) Checks whether all content within the given HTML element should be discarded instead of including it in the parse output.mapSafeAttribute(String elementName, String attributeName) Maps HTML attribute names to Tika's XHTML dialect.mapSafeElement(String name) Maps HTML element names to Tika's XHTML dialect.
-
Method Details
-
mapSafeElement
Maps HTML element names to Tika's XHTML dialect. If the given element is not part of that dialect, this method returnsnulland the element is dropped but the content inside it is still processed. "Safe" here means valid in the output dialect; this is not a browser sanitizer, and attribute values are passed through unchanged. See theisDiscardElement(String)method for a way to discard the entire contents of an element.- Parameters:
name- HTML element name (upper case)- Returns:
- XHTML element name (lower case), or
nullif the element is not in the output dialect
-
isDiscardElement
Checks whether all content within the given HTML element should be discarded instead of including it in the parse output.- Parameters:
name- HTML element name (upper case)- Returns:
trueif content inside the named element should be ignored,falseotherwise
-
mapSafeAttribute
Maps HTML attribute names to Tika's XHTML dialect. If the given attribute is not part of that dialect for this element, this method returnsnull, and the attribute is dropped. Attribute values are not inspected. This method assumes that the element name is valid and normalised.- Parameters:
elementName- HTML element name (lower case)attributeName- HTML attribute name (lower case)- Returns:
- XHTML attribute name (lower case), or
nullif the attribute is not in the output dialect
-