[jdom-interest] StreamResult JDOMSource Transformer problem

Rich Baldwin Rich.Baldwin at noaa.gov
Tue Sep 27 12:43:01 PDT 2005


I trying to transform an xml document generated from a database call to 
a text output file.  This works fine when System.out is specified in the 
StreamResult, but when a File is defined I get a

javax.xml.transform.TransformerException: java.io.FileNotFoundException: 
home/username/Java/final.xml (No such file or directory)
        at 
org.apache.xalan.transformer.TransformerImpl.createResultContentHandler(Unknown 
Source)
        at 
org.apache.xalan.transformer.TransformerImpl.createResultContentHandler(Unknown 
Source)
        at 
org.apache.xalan.transformer.TransformerImpl.transform(Unknown Source)

Is there something about StreamResult or JDOMSource that the Transformer 
doesn't like?

Tx, Rich

Here is a code snippet:
public class xmlquerydb_xsl
{
  public static void main(String args[]) throws SQLException
  {
   File outfile = null;
    
System.setProperty("javax.xml.transform.TransformerFactory","org.apache.xalan.processor.TransformerFactoryImpl");
    
System.setProperty("javax.xml.parsers.SAXParserFactory","org.apache.xerces.jaxp.SAXParserFactoryImpl");
//  File output fails
    //File outfile = new File("final.xml");
    //StreamResult out = new StreamResult(outfile);
// System.out works
    StreamResult out = new StreamResult(System.out); 
    ""
//  Connect to database generate xml document  
        OracleXMLQuery qry = new OracleXMLQuery(conn, query);
        Document domDoc = (Document) qry.getXMLDOM();
         org.jdom.input.DOMBuilder builder = new 
org.jdom.input.DOMBuilder();
         org.jdom.Document jdomDoc = builder.build(domDoc);
         JDOMSource src = new JDOMSource(jdomDoc);

        TransformerFactory transformerfactory = 
TransformerFactory.newInstance();
        Transformer xf = transformerfactory.newTransformer(new 
StreamSource("space-delimited.xsl")); 
        xf.setOutputProperty(OutputKeys.ENCODING,"US-ASCII");
        xf.setOutputProperty(OutputKeys.INDENT,"yes");
        xf.transform(src,out);
  "
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rich.baldwin.vcf
Type: text/x-vcard
Size: 125 bytes
Desc: not available
Url : http://www.jdom.org/pipermail/jdom-interest/attachments/20050927/38a0b777/rich.baldwin.vcf


More information about the jdom-interest mailing list