File or XSLT issue?
Hi,
I've been trying to get an xslt working within java but with no luck.
What I'm trying to do is upload a file and execute an XSLT on it. I
don't have much experience with either File or XSLT but what I've
found happening is the data in the file is being completly deleted!?!
The error I'm getting back is:
ERROR: 'Premature end of file.'
ERROR:
'com.sun.org.apache.xml.internal.utils.WrappedRuntimeException:
Premature end of file.'
It could be the way I'm reading the file into the java and not to do
with xslt?
Thanks for your help,
Gaffer
This is code I have for the button listener:
saveb.addSelectionListener(new SelectionAdapter(){
public void widgetSelected(SelectionEvent e) {
try{
String fileNamePublish = qmediafile_loc.getText(); //file
slected at runtime
FileOutputStream fos = new
FileOutputStream(fileNamePublish);
File xmlFile = new File(fileNamePublish);
File xsltFile = new File("C:/test.xsl");
Source xmlSource = new StreamSource(xmlFile);
Source xsltSource = new StreamSource(xsltFile);
TransformerFactory transFact =
TransformerFactory.newInstance();
try{
Transformer trans =
transFact.newTransformer(xsltSource);
trans.transform(xmlSource, new
StreamResult(System.out));
}catch(TransformerException me ) {}
}catch(IOException ioe) {}
}
});