JDK-8230824 : Enable SAX ContentHandler to handle XML Declaration
  • Type: CSR
  • Component: xml
  • Sub-Component: jaxp
  • Priority: P4
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 14
  • Submitted: 2019-09-10
  • Updated: 2019-12-23
  • Resolved: 2019-09-13
Related Reports
CSR :  
Description
Summary
-------

Add a method to SAX ContentHandler to handle the XML Declaration event.

Problem
-------

The SAX ContentHandler defines callback methods for SAX Parsers to send content information such as elements, characters and etc. back to the application. However, it omitted the XML Declaration, using it only for the SAX Parser to make its own configurations. This is a problem for applications that wish to read the declaration for configuring readers or writers, and preserving the declaration of the source.

Solution
--------

Add a callback method to SAX ContentHandler to handle the XML Declaration event.

Specification
-------------

org.xml.sax

public interface ContentHandler

    /**
     * Receives notification of the XML declaration.
     * 
     * @implSpec
     * The default implementation in the SAX API is to do nothing.
     * 
     * @param version the version string as in the input document, null if not
     * specified
     * @param encoding the encoding string as in the input document, null if not
     * specified
     * @param standalone the standalone string as in the input document, null if 
     * not specified
     * 
     * @throws SAXException if the application wants to report an error or
     * interrupt the parsing process
     */
    default void declaration(String version, String encoding, String standalone)
        throws SAXException
    {
        //no op
    }


Comments
Moving to Approved.
13-09-2019