Class HTMLURIEscaper

All Implemented Interfaces:
Result, Receiver
Direct Known Subclasses:
XHTMLURIEscaper

public class HTMLURIEscaper extends ProxyReceiver
This class is used as a filter on the serialization pipeline; it performs the function of escaping URI-valued attributes in HTML
  • Field Details

    • currentElement

      protected NodeName currentElement
    • escapeURIAttributes

      protected boolean escapeURIAttributes
    • pool

      protected NamePool pool
  • Constructor Details

    • HTMLURIEscaper

      public HTMLURIEscaper(Receiver nextReceiver)
  • Method Details

    • isUrlAttribute

      public boolean isUrlAttribute(NodeName element, NodeName attribute)
    • startDocument

      public void startDocument(int properties) throws XPathException
      Start of a document node.
      Specified by:
      startDocument in interface Receiver
      Overrides:
      startDocument in class ProxyReceiver
      Parameters:
      properties - bit-significant integer indicating properties of the document node. The definitions of the bits are in class ReceiverOption
      Throws:
      XPathException - if an error occurs
    • startElement

      public void startElement(NodeName nameCode, SchemaType type, AttributeMap attributes, NamespaceMap namespaces, Location location, int properties) throws XPathException
      Notify the start of an element
      Specified by:
      startElement in interface Receiver
      Overrides:
      startElement in class ProxyReceiver
      Parameters:
      nameCode - the name of the element.
      type - the type annotation of the element.
      attributes - the attributes of this element
      namespaces - the in-scope namespaces of this element: generally this is all the in-scope namespaces, without relying on inheriting namespaces from parent elements
      location - an object providing information about the module, line, and column where the node originated
      properties - bit-significant properties of the element node. If there are no relevant properties, zero is supplied. The definitions of the bits are in class ReceiverOption
      Throws:
      XPathException - if an error occurs
    • escapeURL

      public static String escapeURL(String url, boolean normalize, Configuration config) throws XPathException
      Escape a URI according to the HTML rules: that is, a non-ASCII character (specifically, a character outside the range 32 - 126) is replaced by the %HH encoding of the octets in its UTF-8 representation
      Parameters:
      url - the URI to be escaped
      normalize - true if Unicode normalization (to NFC) is required
      config - the configuration
      Returns:
      the URI after escaping non-ASCII characters
      Throws:
      XPathException - if any error occurs