Class DefaultHtmlMapper

java.lang.Object
org.apache.tika.parser.html.DefaultHtmlMapper
All Implemented Interfaces:
HtmlMapper

public class DefaultHtmlMapper extends Object implements HtmlMapper
The default HTML mapping rules in Tika.
Since:
Apache Tika 0.6
  • Field Details

    • INSTANCE

      public static final HtmlMapper INSTANCE
      Since:
      Apache Tika 0.8
  • Constructor Details

    • DefaultHtmlMapper

      public DefaultHtmlMapper()
  • Method Details

    • mapSafeElement

      public String mapSafeElement(String name)
      Description copied from interface: HtmlMapper
      Maps HTML element names to Tika's XHTML dialect. If the given element is not part of that dialect, this method returns null and 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 the HtmlMapper.isDiscardElement(String) method for a way to discard the entire contents of an element.
      Specified by:
      mapSafeElement in interface HtmlMapper
      Parameters:
      name - HTML element name (upper case)
      Returns:
      XHTML element name (lower case), or null if the element is not in the output dialect
    • mapSafeAttribute

      public String mapSafeAttribute(String elementName, String attributeName)
      Normalizes an attribute name. Assumes that the element name is valid and normalized
      Specified by:
      mapSafeAttribute in interface HtmlMapper
      Parameters:
      elementName - HTML element name (lower case)
      attributeName - HTML attribute name (lower case)
      Returns:
      XHTML attribute name (lower case), or null if the attribute is not in the output dialect
    • isDiscardElement

      public boolean isDiscardElement(String name)
      Description copied from interface: HtmlMapper
      Checks whether all content within the given HTML element should be discarded instead of including it in the parse output.
      Specified by:
      isDiscardElement in interface HtmlMapper
      Parameters:
      name - HTML element name (upper case)
      Returns:
      true if content inside the named element should be ignored, false otherwise