• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

xml/xslt/jsp Usage patterns...?

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I have a question regarding xml, xlst, and jsp.
I'm using...
WebSphere 4.04
Xerces 2.5.1
Xalan 2.5.1
I am currently developing an application that retreives an xml document from a database, applies any of several different xslt documents to the xml file and displays it inside of a jsp. I have done some research and found that most people have the xml and xsl documents as files and use a Transform.transform(Source, OutputStream) to display the transformed xml document.
My questions are...
1. Since my xml document lives in a database is there a way to pass the xml document object to the transformer, or do I HAVE to save it as a file to the server's file system and then pass the path to the 'temporary' document as an argument?
2. The all of the transformer examples I have looked at create an output stream to get the transformed data to the client. Is there anyway I can capture the output and store it into a String or StringBuffer? I realize this is more of an IO issue but I am trying to generate this output to an object that can placed into the session and displayed inside of a jsp page.
Based on what I seen I have to treat the generation of the transformed document as I would the generation of an image. (i.e. I create a jsp with an include tag that calls a url with arguments. That url is to a servlet/action class combo that retrieves the xml transforms it and just spits the data back to the client via the output stream.)
3. Is this a "best practice", acceptable solution or am I going down a wrong path?
Just looking for validation and/or other options.
Thanks for your time.
 
author and deputy
Posts: 3150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Heath Lilley:
Hello,
2. The all of the transformer examples I have looked at create an output stream to get the transformed data to the client. Is there anyway I can capture the output and store it into a String or StringBuffer? I realize this is more of an IO issue but I am trying to generate this output to an object that can placed into the session and displayed inside of a jsp page.


Answer to your 2nd question.
Here is the same code for doing this

You can the the variable content to write to a file using Java.IO now.
Rgd question 1
The other way(if the XML file is small), you can read the XML file from database,store it on a stringbuffer and give it directly to the transformer obejct, see line2 of the above code.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic