Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8259700 | 16-pool | Kiran Sidhartha Ravikumar | P3 | New | Unresolved | |
JDK-8259701 | 11-pool | Kiran Sidhartha Ravikumar | P3 | New | Unresolved | |
JDK-8259702 | 8-pool | Kiran Sidhartha Ravikumar | P3 | New | Unresolved | |
JDK-8259703 | 7-pool | Kiran Sidhartha Ravikumar | P3 | New | Unresolved |
Using LSSerializer to pretty-print a DOM results in an xml-declaration being not followed by a newline.
Related to bugs #7150637 and #8054115.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the following code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
<?xml version="1.0" encoding="UTF-8"?>
<sometag/>
ACTUAL -
<?xml version="1.0" encoding="UTF-8"?><sometag/>
---------- BEGIN SOURCE ----------
package io.github.oliviercailloux.jaris.xml;
import java.io.StringWriter;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.ls.DOMImplementationLS;
import org.w3c.dom.ls.LSOutput;
import org.w3c.dom.ls.LSSerializer;
public class Snippet {
public static void main(String[] args) throws Exception {
final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
final DocumentBuilder builder = factory.newDocumentBuilder();
final Document document = builder.newDocument();
final Element child = document.createElement("sometag");
document.appendChild(child);
final DOMImplementationLS impl = (DOMImplementationLS) document.getImplementation().getFeature("LS", "3.0");
final LSSerializer ser = impl.createLSSerializer();
/** But see https://bugs.openjdk.java.net/browse/JDK-7150637 */
/**
* But see
* <a href="https://bugs.openjdk.java.net/browse/JDK-8054115">8054115</a>:
* LSSerializer remove a '\n' following the xml declaration
*/
ser.getDomConfig().setParameter("format-pretty-print", true);
final StringWriter writer = new StringWriter();
final LSOutput output = impl.createLSOutput();
output.setCharacterStream(writer);
ser.write(document, output);
System.out.println(writer.toString());
}
}
---------- END SOURCE ----------
FREQUENCY : always
- backported by
-
JDK-8259700 xml declaration is not followed by a newline
-
- New
-
-
JDK-8259701 xml declaration is not followed by a newline
-
- New
-
-
JDK-8259702 xml declaration is not followed by a newline
-
- New
-
-
JDK-8259703 xml declaration is not followed by a newline
-
- New
-
- csr for
-
JDK-8259352 DOM LSSerializer control of newline after XML header
-
- Provisional
-
- relates to
-
JDK-8054115 LSSerializer remove a '\n' following the xml declaration
-
- Resolved
-
-
JDK-7150637 No newline emitted after XML decl in XSLT output
-
- Closed
-
-
JDK-8259704 DOM LSSerializer control of newline after XML header
-
- Draft
-
-
JDK-8258803 WLS/Tuxedo error in encoding post JDK upgrade
-
- Open
-
-
JDK-8250879 Create XML File - no indentation - one long row
-
- Closed
-
- links to
-
Review openjdk/jdk/2041