Class XmlHtml

java.lang.Object
org.libxmq.imp.xml.XmlHtml

public final class XmlHtml extends Object
The html tables of libxml2 2.16 used by the html parser and the html writer: the elements, which start tags implicitly close which open elements, the end tag priorities, the elements allowing pcdata, the boolean attributes and the html5 named character references. A port of xml_html.c.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final record 
    An html element.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Plain text, the rest of the input.
    static final int
    Raw text, eg style.
    static final int
    The data modes (tokenizer states) of the content of an element.
    static final int
    Script data.
    static final int
    Script data after <!
    static final int
    Script data after <!
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    Elements where ignorable whitespace is kept since they allow pcdata.
    Look up an html element (case insensitive), null if unknown.
    static int
    The end tag priority: an end tag only closes elements with lower or equal priority.
    static byte[]
    findEntityPrefix(byte[] s, int off, int slen, boolean is_attr, int[] nlen)
    Find the longest html5 named character reference that is a prefix of the bytes s[off..off+slen) (which start after the &), port of libxml2 htmlFindEntityPrefix.
    static boolean
    Attributes written in minimized form, eg checked or selected (case insensitive), libxml2 htmlIsBooleanAttr.
    static boolean
    startCloses(String new_tag, String old_tag)
    Does a start tag new_tag implicitly close an open element old_tag?

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DATA_RCDATA

      public static final int DATA_RCDATA
      The data modes (tokenizer states) of the content of an element.
      See Also:
    • DATA_RAWTEXT

      public static final int DATA_RAWTEXT
      Raw text, eg style.
      See Also:
    • DATA_PLAINTEXT

      public static final int DATA_PLAINTEXT
      Plain text, the rest of the input.
      See Also:
    • DATA_SCRIPT

      public static final int DATA_SCRIPT
      Script data.
      See Also:
    • DATA_SCRIPT_ESC1

      public static final int DATA_SCRIPT_ESC1
      Script data after <!--.
      See Also:
    • DATA_SCRIPT_ESC2

      public static final int DATA_SCRIPT_ESC2
      Script data after <!--<script.
      See Also:
  • Method Details

    • element

      public static XmlHtml.Element element(String name)
      Look up an html element (case insensitive), null if unknown.
      Parameters:
      name - The element name.
      Returns:
      The element or null.
    • startCloses

      public static boolean startCloses(String new_tag, String old_tag)
      Does a start tag new_tag implicitly close an open element old_tag? (lowercase names)
      Parameters:
      new_tag - The new start tag.
      old_tag - The open element.
      Returns:
      True if old_tag is closed.
    • endPriority

      public static int endPriority(String name)
      The end tag priority: an end tag only closes elements with lower or equal priority.
      Parameters:
      name - The element name.
      Returns:
      The priority.
    • allowsPcdata

      public static boolean allowsPcdata(String name)
      Elements where ignorable whitespace is kept since they allow pcdata.
      Parameters:
      name - The element name.
      Returns:
      True if the element allows pcdata.
    • isBooleanAttr

      public static boolean isBooleanAttr(String name)
      Attributes written in minimized form, eg checked or selected (case insensitive), libxml2 htmlIsBooleanAttr.
      Parameters:
      name - The attribute name.
      Returns:
      True if boolean.
    • findEntityPrefix

      public static byte[] findEntityPrefix(byte[] s, int off, int slen, boolean is_attr, int[] nlen)
      Find the longest html5 named character reference that is a prefix of the bytes s[off..off+slen) (which start after the &), port of libxml2 htmlFindEntityPrefix.
      Parameters:
      s - The input bytes.
      off - The offset of the reference name.
      slen - The number of bytes available.
      is_attr - True inside an attribute value.
      nlen - Set to the number of bytes of the reference (excluding the &, including a ; if present).
      Returns:
      The utf8 replacement, or null if there is none.