Hi Vincent,
I assume that using of "com.sun.star.comp.Writer.XMLOasisExporter"
instead of "com.sun.star.comp.Writer.XMLExporter" would let the ODT XML
format be used.
Best regards,
Mikhail.
Vincent Spiewak wrote:
Hi all
I want to store an ODT "Flat XML" of the current document.
I tried this code from "SAXEcho" project:
DocumentCollector collector = new DocumentCollector(false);
// get the xmlexportfilter service
XMultiComponentFactory m_xMCF = m_xContext.getServiceManager();
Object xmlExporter = null;
xmlExporter =
m_xMCF.createInstanceWithContext("com.sun.star.comp.Writer.XMLExporter",
m_xContext);
// get the interface of xmlexportfilter service
XFilter xFilter = (XFilter)
UnoRuntime.queryInterface(XFilter.class, xmlExporter);
XExporter xExporter = (XExporter)
UnoRuntime.queryInterface(XExporter.class, xmlExporter);
XInitialization xInitialization =
(XInitialization)
UnoRuntime.queryInterface(XInitialization.class, xmlExporter);
Object args[] = new Object[1];
args[0] = (com.sun.star.xml.sax.XDocumentHandler)
UnoRuntime.queryInterface(
com.sun.star.xml.sax.XDocumentHandler.class, collector);
xInitialization.initialize(args);
// get the Desktop service
Object desktop = m_xMCF.createInstanceWithContext(
"com.sun.star.frame.Desktop", m_xContext);
XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(
XDesktop.class, desktop);
// set the xcomponent
xExporter.setSourceDocument(xDesktop.getCurrentComponent());
// start the filter
xFilter.filter(new PropertyValue[0]);
Document root = collector.getDocument();
AdapterNode adapter = new AdapterNode(root, null);
// saving...
FileOutputStream fos = new FileOutputStream(tmpUrl);
DocumentDistributor.setFormatting(false);
DocumentDistributor.parseNode(adapter.getNode(), fos, null);
fos.close();
It works great but give a SXW Flat XML, NOT ODT.
Is there a similar way to export in ODT Flat XML ?
Instead, is there any Java Toolkit like AODL ?
----------------------------------------------------------
- Vincent Spiewak - www.versusoft.com -
----------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]