Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8249867 XML declaration is not followed by a newline
  3. JDK-8259502

Release Note: DOM LSSerializer control of newline after XML header

    XMLWordPrintable

Details

    • Sub-task
    • Resolution: Duplicate
    • P4
    • None
    • None
    • xml
    • None

    Description

      The DOM Load and Save `LSSerializer` does not have an explicit control for whether or not the XML Declaration ends with a newline. In this release, a JDK implementation specific property `http://www.oracle.com/xml/jaxp/properties/isStandalone` and corresponding System property `jdk.xml.isStandalone` are added to control the addition of a newline and acts independently without having to set the pretty-print property. This property can be used to reverse the incompatible change introduced in Java SE 7 Update 4 with an update of Xalan 2.7.1 where a newline is omitted when pretty-print is required.

      For details, please refer to the bug report and the java.xml module-summary.

      Usage:
      ```
          // to set the property, get an instance of LSSerializer and set it along with pretty-print
          LSSerializer ser = impl.createLSSerializer();
          ser.getDomConfig().setParameter("format-pretty-print", true);
          ser.getDomConfig().setParameter("http://www.oracle.com/xml/jaxp/properties/isStandalone", true);

          // to use the System property, set it before initializing a LSSerializer
          System.setProperty("jdk.xml.isStandalone", “true”);

          // to clear the property, place the line anywhere after the LSSerializer is initialized
          System.clearProperty("jdk.xml.isStandalone");

      ```

      Attachments

        Issue Links

          Activity

            People

              joehw Joe Wang
              joehw Joe Wang
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: