This week's giveaway is in the Spring forum.
We're giving away four copies of Microservices Testing (Live Project) and have Chris Love & Andres Sacco on-line!
See this thread for details.
Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

JAVA,XML ,WRiter

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear masters,
I want to create an XML page in runtime using JAVA Document.please kindly help me
thank you
 
Leverager of our synergies
Posts: 10065
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).]
 
reply
    Bookmark Topic Watch Topic
  • New Topic