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

Enable SAX ContentHandler to handle XML Declaration

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 14
    • xml
    • None
    • minimal
    • There is no compatibility risk. The request proposes adding a new default method, that does not change the existing behavior.
    • Java API
    • SE

      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
      }

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

              Created:
              Updated:
              Resolved: