2017-10-27 34 views
0

マーシャルされたxmlとxsltといくつかの問題でoutFileベースを生成しようとしています。TransformerException:ファイルの早期終了エラーが発生しました

オブジェクトからxmlストリームを生成するコードです。

JAXBContext jaxbContext = JAXBContext.newInstance(EmployeeFormat.class); 
ByteArrayOutputStream os = new ByteArrayOutputStream(); 
Marshaller marshaller = jaxbContext.createMarshaller(); 
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);   
marshaller.marshal(employeeFormat,os); 
outEmpFile(new ByteArrayInputStream(os.toByteArray())); 

この方法は、コードを実行しているとき、私はTransformerExceptionを取得してoutFileが入力

public void outEmpFile(ByteArrayInputStream inputStream) throws IOException { 
    File template = new File("C/workspace/files/Employee.xslt"); 
    File outFile = new File(C:/workspace/files/Employee.java"); 

    TransformerFactory transformerFactory = TransformerFactory.newInstance(); 
    Transformer transformer = transformerFactory.newTransformer(new StreamSource(template));    
    transformer.transform(new StreamSource(inputStream),new StreamResult(outFile)); 
} 

としてXMLを取って生成します。

ERROR: 'Premature end of file.'javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: 

    com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: Premature end of file. 

両方の入力XMLとXSLTは、オンラインツールで期待される出力を生成します - http://www.utilities-online.info/xsltransformation

このコードは、コンソールで正しいxmlファイルを指定します。

問題のヘルプをお願いします。

答えて

関連する問題