Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8230824

Enable SAX ContentHandler to handle XML Declaration

    XMLWordPrintable

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P4
    • Resolution: Approved
    • Fix Version/s: 14
    • Component/s: xml
    • Labels:
      None
    • Subcomponent:
    • Compatibility Risk:
      minimal
    • Compatibility Risk Description:
      There is no compatibility risk. The request proposes adding a new default method, that does not change the existing behavior.
    • Interface Kind:
      Java API
    • Scope:
      SE

      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
      }

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              joehw Joe Wang
              Reporter:
              joehw Joe Wang
              Reviewed By:
              Daniel Fuchs, Lance Andersen
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: