Link to home
Start Free TrialLog in
Avatar of csound
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().newTransformer(styleSource);                  
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?
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Have you called

editorPane.setContent("text/html");

?
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of csound
csound

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.