public static XDocumentHandler getFileXMLWriter(XMultiServiceFactory xMSF, String fileURL)
throws com.sun.star.uno.Exception
{
XInterface oFacc = (XInterface)xMSF.createInstance(
"com.sun.star.comp.ucb.SimpleFileAccess");
XSimpleFileAccess xFacc = (XSimpleFileAccess)UnoRuntime.queryInterface
(XSimpleFileAccess.class, oFacc) ;
XInterface oWriter = (XInterface)xMSF.createInstance(
"com.sun.star.xml.sax.Writer");
XActiveDataSource xWriterDS = (XActiveDataSource)
UnoRuntime.queryInterface(XActiveDataSource.class, oWriter);
XDocumentHandler xDocHandWriter = (XDocumentHandler) UnoRuntime.queryInterface
(XDocumentHandler.class, oWriter) ;
if (xFacc.exists(fileURL))
xFacc.kill(fileURL);
XOutputStream fOut = xFacc.openFileWrite(fileURL) ;
xWriterDS.setOutputStream(fOut);
return xDocHandWriter ;
}