browser display

hi guys,i have to create an html file from xml using xsl and I want to display the html in a browser when i execute the java program without storing the html file onto disk.thanks in advance.rajiv
[224 byte] By [rajiv_kinga] at [2007-11-26 18:17:10]
# 1

Although you didn't ask a question, I guess you want to know how to achieve this. There are at least 2 ways:

a) translate XML via XSL on the fly and make the transformer push the result to the client stream

b) add a stylesheet reference into the XML file and transfer it to the client (if it's capable of processing XSLT, such as Firefox or IE 5/5.5 or later)

quittea at 2007-7-9 5:50:44 > top of Java-index,Java Essentials,Java Programming...
# 2

dear friend,

thank u for ur reply.

I have an xml file and xsl file.And I wish to write a java program for converting xml to html using my xsl and the resulting html document is to be displayed in a browser without storing onto the disk.

It is not for server side purpose.Its only a standalone java application

Message was edited by:

rajiv_king

rajiv_kinga at 2007-7-9 5:50:44 > top of Java-index,Java Essentials,Java Programming...
# 3
Are you doing the conversion local, or remote?What do you want to not store, the XML file? The XSL? The final HTML file?Why not let the browser doing the XSL converting?
mlka at 2007-7-9 5:50:44 > top of Java-index,Java Essentials,Java Programming...
# 4
Just as mlk suggested, I'd go for the client-conversion method, so you don't have to do any XSLT processing in Java at all. Otherwise, you either have to create a temporary file or initialize a HTTP server within your application (see Jetty for example).
quittea at 2007-7-9 5:50:44 > top of Java-index,Java Essentials,Java Programming...
# 5

hello mlk

thanks ur reply.we want to write a java program for creating html document using xml and xsl.We already have xml and xsl.We wish to display the resulting html in a browser when we execute the program..

We dont want to store the html document in a disk...hope u get our problem...

thanks in advance....

rajiv

rajiv_kinga at 2007-7-9 5:50:44 > top of Java-index,Java Essentials,Java Programming...
# 6
As a test: add the following line (adjusted to your personal settings) into one of your XML files (before the root element) and open it in a browser of your choice:<?xml-stylesheet type="text/xsl" href="path/filename.xsl" ?>
quittea at 2007-7-9 5:50:44 > top of Java-index,Java Essentials,Java Programming...
# 7

> Otherwise, you either

> have to create a temporary file or initialize a HTTP

> server within your application (see Jetty for

> example).

Or use a pure Java web browser that can read from a stream, and have the browser embedded as part of the application that does the conversion.

But why do you not want to create a temp file?

mlka at 2007-7-9 5:50:44 > top of Java-index,Java Essentials,Java Programming...
# 8

hello mlk and squitte,

thanks for ur reply....we have a xml file and xsl file and we used java program to create a html file using javax.xml.transform api...when we execute program,an html file is created in our disk.And we manually click tht html for displaying.We wish to display html when we execute our pgm.Doest want to create a html file.

rajiv_kinga at 2007-7-9 5:50:44 > top of Java-index,Java Essentials,Java Programming...
# 9
Yes, so much we've understood this, several proposals have been given. Have you evaluated these?
quittea at 2007-7-9 5:50:44 > top of Java-index,Java Essentials,Java Programming...
# 10
hii read all these stuffs..but didnt get an idea...
rajiv_kinga at 2007-7-9 5:50:44 > top of Java-index,Java Essentials,Java Programming...
# 11

As a summary, you have the following ways:

a) Do XSLT processing as currently, try to find a fully-featured, Java-enabled HTML display component and either divert XSLT output to this component or divert it into a character buffer and hand the result over to the component.

b) Do XSLT processing as currently, diverting the output into a temporary file, then open this file using the default browser. You said you wouldn't like temporary files, though you didn't give a reason why.

c) Do XSLT processing as currently, embed a freely available HTTP listener such as Jetty into your application and make the default browser open a localhost URL that leads to your XSLT processing module. Divert the processing output into the response stream of this HTTP listener (e.g. by creating a Servlet doing the XSLT transformation).

d) Stop processing XSLT in Java, but add a reference to the XSLT file into the XML file and open this XML file using the default browser. Modern browsers are capable of transforming XSLT for themselves.

quittea at 2007-7-9 5:50:44 > top of Java-index,Java Essentials,Java Programming...
# 12
thank u for ur help...lemmet try it
rajiv_kinga at 2007-7-9 5:50:44 > top of Java-index,Java Essentials,Java Programming...