• 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

transformation of xml & xsl w/out files or Strings

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using FOP and I have a java String representation of XML which I create dynamically by writing out the properties of my model. Anyway my XML is too big for a java String. What and how is another way of dynamically creating XML not using java Files or Strings and still use the transformer?
Here is my code:
//set up XML using java String
Source xmlSource = new StreamSource(new StringReader(xmlString));
//set up transformer
Source xsltSrc = new StreamSource(new File(xslParam));
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer(xsltSrc);
//start the transformation and render
transformer.transform(xmlSource,res);
[ February 10, 2004: Message edited by: jay ]
[ February 10, 2004: Message edited by: jay ]
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I suspect that if your String representation is so large, FOP is going to choke, but anyway, you might be able to feed the FOP transformer running in one Thread while you write the XML in another Thread. Look at the PipedInputStream / PipedOutputStream pair of classes in the java.io package.
They are designed for connecting the output from one Thread with input used by another.
Bill
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic