Class HTMLURIEscaper

  • All Implemented Interfaces:
    javax.xml.transform.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 Detail

      • currentElement

        protected NodeName currentElement
      • escapeURIAttributes

        protected boolean escapeURIAttributes
    • Constructor Detail

      • HTMLURIEscaper

        public HTMLURIEscaper​(Receiver nextReceiver)
    • Method Detail

      • isUrlAttribute

        public boolean isUrlAttribute​(NodeName element,
                                      NodeName attribute)
      • 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 java.lang.String escapeURL​(java.lang.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