JDK-8259502 : Release Note: DOM LSSerializer control of newline after XML header
  • Type: Sub-task
  • Component: xml
  • Sub-Component: jaxp
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • Submitted: 2021-01-08
  • Updated: 2021-06-02
  • Resolved: 2021-02-17
Related Reports
Duplicate :  
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");

``` 

Comments
Release notes for implementation specific features and properties have been consolidated into one document. See JDK-8261861.
17-02-2021

When the javadoc of Java 17 is ready to be published, it would be nice to add a link to "java.xml module-summary", e.g. <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.xml/module-summary.html">java.xml module-summary</a>.
01-02-2021