wood burning stoves 2.0*
The moose likes XML and Related Technologies and the fly likes Query on StreamResult object for storing transformed xml doc Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Query on StreamResult object for storing transformed xml doc" Watch "Query on StreamResult object for storing transformed xml doc" New topic
Author

Query on StreamResult object for storing transformed xml doc

Colm Dickson
Ranch Hand

Joined: Apr 04, 2009
Posts: 89
Hi all,


I was puzzled recently as to why the code I had was throwing an IO FileNotFound error when I had



but worked when I simply used




There is a constructor for Streamresult that takes a File object which I though was correct in the first example. can someone explain what is happeneing here. I would have expected the file to be created with the transformed data in my C drive using example one ...Also , would it be right to say that the second example which works is using the constructor for StrreamResult that takes a string (Construct a StreamResult from a URL.)...becasue such a constructor exists?


Thanks

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

That second example is surely the constructor which expects a URL in String form. What you posted there isn't a URL, so I'm surprised that it worked. I'm also surprised that the first example didn't. My conclusion from all of that is that you have got your tests backwards; the first example should work (assuming that file exists) and the second should not.
Colm Dickson
Ranch Hand

Joined: Apr 04, 2009
Posts: 89
Thanks for replying.

Yes it's strange and I checked again and the new File argument does indeed fail and the String URL one works and creates a file with that name in my project directory yet specifying new File("C:\\filename") causes an IO error and this location is fully writable.


Trying this method below however does work




Colm
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 499
    
    3
If you're still using jdk 1.3.1 or about, you should consider update jdk. There was a bug on 1.3.1 for constructor StreamResult(File).
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5052510
It should have been fixed in 1.5 or higher.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Query on StreamResult object for storing transformed xml doc
 
Similar Threads
JAXP 1.1 transform issue using DOMSource
FileWriter experience
DOM Parser
StreamSource/StreamResult
XML transformation - choice between using Reader and Stream