Dear masters, I want to create an XML page in runtime using JAVA Document.please kindly help me thank you
Leverager of our synergies
Joined: Aug 26, 2000
Sridhar, Zaeem Masood Ashar does exactly this in the next thread On Monday Ajith will solve all problems and until then you can just look at the code and try your version. Also, your name doesn�t comply with our Official policy on registered names, unfortunately You are required to have a name of at least two words, separated by a space, and it�s great if they all are real.
Since an XML document is a plain ASCII-based text file, you have the following options -
[list] Let your Java program create a String representation of the XML. Since many XML applications/parsers are capable of handling XML data either from a file or from a String stream, you shouldn't have any problems interpreting or using the XML String. Example -
Whenever you want to convert your Object to an XML representation, you can simply call this method. [/list]
Let your Java program create an XML document ( for example, using the method as mentioned above, ) save it in a file and pass the client(s) a reference to this file. This approach would help you decouple the XML creation and consumption and can be a very good solution in situations where the client needs access to the XML beyond the lifetime of the server process.
Use the DOM approach - Using DocumentFragment, you can create a partial XML tree and pass the object to the client process. This approach has several drawbacks - at the least, the client should have access to a DOM parser, passing a DOM tree back and forth across a network will cause performance overheads. If the client decides to use a SAX parser OR would like the XML document to be available "offline" beyond the life of the server process, this approach is no good.
Sun is working on XML Databinding( JAXB ) infrastructure that will allow you to seamlessly persist an object( of any class type ) into an XML document and read such documents to create objects at runtime. Whenit matures, this facility will greatly enhance XML-ability of Java classes and will alleviate the burden of writing messy toXMLString() method for all your classes. Checkout the JSR on Sun's website.
Hope this gives you an idea about how to proceed. Cheers!
[This message has been edited by Ajith Kallambella (edited May 07, 2001).]
Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).