Here is surprising behaviour. I create a JTextPane , set it up to use HTMLEditorKit, and fill it with valid HTML. But by default Java's HTMLWriter creates invalid HTML. Most items are serialised out correctly but img tags lose their closing slash so :
<img src="https://localhost:9443/ccm/service/com.ibm.team.workitem.common.internal.model.IImageContentService/processattachment/_7rfpIMXdEeGLRroh_7O2yQ/workflow/resolve.gif" alt="Resolved" border="0"/>
is written as :
<img src="https://localhost:9443/ccm/service/com.ibm.team.workitem.common.internal.model.IImageContentService/processattachment/_7rfpIMXdEeGLRroh_7O2yQ/workflow/resolve.gif" alt="Resolved" border="0">
I'm using defaults for everything. Why does it not work, is there any easy fix?
Here is a code snippet:
JTextPane editor = new JTextPane();
HTMLEditorKit htmlKit = new HTMLEditorKit();
editor.setContentType("text/html");
editor.setEditorKit(htmlKit);
editor.setText( '*<ADD SOME VALID HTML FROM A FILE>*' );
HTMLDocument d = (HTMLDocument)editor.getDocument();
StringWriter fw = new StringWriter();
HTMLWriter aHTMLWriter = new HTMLWriter(fw,d);
aHTMLWriter.write();
String txt = fw.toString();
// Now txt is not valid HTML ... eek!