XML Transform results in FileNotFoundException

java, solaris, xml, xslt

Solution

Try to execute below code:

DOMSource sourcexml = new DOMSource(doc);
StreamResult resultxml = new StreamResult(new File("file.xml").getAbsolutePath());
transformer.transform(sourcexml, resultxml); 

Problem

The earlier question I posted is closed because of lack of information. Please let me know if I am missing something here. The transformer seems to be adding file:/ to the beginning of my file path. I am working in a Solaris environment, and here is what happens when the transform gets applied: ``` DOMSource sourcexml = new DOMSource(doc); StreamResult resultxml = new StreamResult(new File("file.xml")); transformer.transform(sourcexml, resultxml); ``` The exception I get is: ``` javax.xml.transform.TransformerException: java.io.FileNotFoundException: file:/opt/origenate/or_dev87/apps/documentarchive/file.xml (No such file or directory) ``` Note, the file exists in /opt/origenate/or_dev87/apps/documentarchive/file.xml, but the transformer object is looking for file:/opt/origenate/or_dev87/apps/documentarchive/file.xml. Why does it append the file:/? Is there anyway I can remove it?

Original source