• 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

problem wrting DOM to file

 
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello:

I have been trying to use the following method to write my Document (chartDoc) to a file:

Source source = new DOMSource(chartDoc);
File file = new File("c:/test/slide11.xml");
Result result = new StreamResult(file);

Transformer xformer = TransformerFactory.newInstance().newTransformer();
xformer.transform(source, result);

The file is created but it is empty. I know that the Document is fine as it is used successfully for other purposes. I have tried using OutputKeys to no avail. Any ideas?

Thanks
Eric
 
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
What provision have you made for catching and logging an error during the Transform stage?

An empty file is what I would expect if the transform() does not terminate normally.

Bill
 
John Eric Hamacher
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No exceptions are thrown. Basically it's a black hole.
 
William Brogden
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
Wow, that is indeed mysterious.
If this was my problem I would try to look at the transformer properties with:

Properties p = xformer.getOutputProperties();
p.list( System.out );

Maybe something there will give us a clue.

Bill
 
reply
    Bookmark Topic Watch Topic
  • New Topic