Class HTMLEmitter

  • All Implemented Interfaces:
    javax.xml.transform.Result, Receiver

    public class HTMLEmitter
    extends XMLEmitter
    This class generates HTML output
    Author:
    Michael H. Kay
    • Field Detail

      • emptyTags

        static HTMLTagHashSet emptyTags
        Table of HTML tags that have no closing tag
    • Constructor Detail

      • HTMLEmitter

        public HTMLEmitter()
        Constructor
    • Method Detail

      • isEmptyTag

        protected static boolean isEmptyTag​(java.lang.String tag)
      • startElement

        public void startElement​(int nameCode,
                                 int typeCode,
                                 int locationId,
                                 int properties)
                          throws XPathException
        Output element start tag
        Specified by:
        startElement in interface Receiver
        Overrides:
        startElement in class XMLEmitter
        Parameters:
        nameCode - integer code identifying the name of the element within the name pool.
        typeCode - integer code identifying the element's type within the name pool. The value -1 indicates the default type, xdt:untyped.
        locationId - an integer which can be interpreted using a LocationProvider to return information such as line number and system ID. If no location information is available, the value zero is supplied.
        properties - bit-significant properties of the element node. If there are no revelant properties, zero is supplied.
        Throws:
        XPathException
      • startContent

        public void startContent()
                          throws XPathException
        Description copied from interface: Receiver
        Notify the start of the content, that is, the completion of all attributes and namespaces. Note that the initial receiver of output from XSLT instructions will not receive this event, it has to detect it itself. Note that this event is reported for every element even if it has no attributes, no namespaces, and no content.
        Specified by:
        startContent in interface Receiver
        Overrides:
        startContent in class XMLEmitter
        Throws:
        XPathException
      • writeAttribute

        protected void writeAttribute​(int elCode,
                                      java.lang.String attname,
                                      java.lang.CharSequence value,
                                      int properties)
                               throws XPathException
        Write attribute name=value pair. Overrides the XML behaviour if the name and value are the same (we assume this is a boolean attribute to be minimised), or if the value is a URL.
        Overrides:
        writeAttribute in class XMLEmitter
        Parameters:
        elCode - The element name is not used in this version of the method, but is used in the HTML subclass.
        attname - The attribute name, which has already been validated to ensure it can be written in this encoding
        value - The value of the attribute
        properties - Any special properties of the attribute
        Throws:
        XPathException
      • writeEscape

        protected void writeEscape​(java.lang.CharSequence chars,
                                   boolean inAttribute)
                            throws java.io.IOException,
                                   XPathException
        Escape characters. Overrides the XML behaviour
        Overrides:
        writeEscape in class XMLEmitter
        Parameters:
        chars - The character sequence containing the string
        inAttribute - Set to true if the text is in an attribute value
        Throws:
        java.io.IOException
        XPathException
      • characters

        public void characters​(java.lang.CharSequence chars,
                               int locationId,
                               int properties)
                        throws XPathException
        Character data.
        Specified by:
        characters in interface Receiver
        Overrides:
        characters in class XMLEmitter
        Parameters:
        chars - The characters
        locationId - an integer which can be interpreted using a LocationProvider to return information such as line number and system ID. If no location information is available, the value zero is supplied.
        properties - Bit significant value. The following bits are defined:
        DISABLE_ESCAPING
        Disable escaping for this text node
        USE_CDATA
        Output as a CDATA section
        NO_SPECIAL_CHARACTERS
        Value contains no special characters
        WHITESPACE
        Text is all whitespace
        Throws:
        XPathException
      • processingInstruction

        public void processingInstruction​(java.lang.String target,
                                          java.lang.CharSequence data,
                                          int locationId,
                                          int properties)
                                   throws XPathException
        Handle a processing instruction.
        Specified by:
        processingInstruction in interface Receiver
        Overrides:
        processingInstruction in class XMLEmitter
        Parameters:
        target - The PI name. This must be a legal name (it will not be checked).
        data - The data portion of the processing instruction
        locationId - an integer which can be interpreted using a LocationProvider to return information such as line number and system ID. If no location information is available, the value zero is supplied.
        properties - Additional information about the PI. The following bits are defined:
        CHECKED
        Data is known to be legal (e.g. doesn't contain "?>")
        Throws:
        XPathException