csound
asked on
Convert XML to HTML and display on to JEditorPane
I have A code to convert XML to HTML like
Document doc = buildDocument();
File styleSheet=new File("makehtml.xsl");
StreamSource styleSource=new StreamSource(styleSheet);
Transformer t = TransformerFactory
.newInstance().newTransfor mer(styleS ource);
ByteArrayOutputStream bout = new ByteArrayOutputStream();
t.transform(new DOMSource(doc), new StreamResult(bout));
Now I want to display the HTML in a JEditorPane. My current code is like
bout.toByteArray()
ByteArrayInputStream bin = new ByteArrayInputStream(data) ;
JEditorPane editorPane=new JEditorPane();
editorPane.read(bin, new HTMLDocument());
but this displays the source code(tags) of HTML. How can I display the html correctly?
Document doc = buildDocument();
File styleSheet=new File("makehtml.xsl");
StreamSource styleSource=new StreamSource(styleSheet);
Transformer t = TransformerFactory
.newInstance().newTransfor
ByteArrayOutputStream bout = new ByteArrayOutputStream();
t.transform(new DOMSource(doc), new StreamResult(bout));
Now I want to display the HTML in a JEditorPane. My current code is like
bout.toByteArray()
ByteArrayInputStream bin = new ByteArrayInputStream(data)
JEditorPane editorPane=new JEditorPane();
editorPane.read(bin, new HTMLDocument());
but this displays the source code(tags) of HTML. How can I display the html correctly?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
oh... I didn't. It works now thanx. Can I ask one more question please? I've just noticed that the JEditorPane didn't display a table. It displayed information in tabular form but didn't display borders. Whay is this?
I'm afraid the html support is very limited, so it wouldn't surprise me if table borders were not supported.
editorPane.setContent("tex
?