Page 1 of 1

Help with Style XML

Posted: Mon Jan 14, 2008 4:39 am
by scottaf
Hello,

I'm writing some software in java to merge styles from one document to another however can't seem to get the import of styles to work at all. I have tried using the XDocumentHandler to import the style xml elements from office:document-styles on down but no luck. Here is how I setup the importers ( I tried XMLImporter and XMLStylesImporter). Do I need and external xsl to accomplish this?

Object xmlImporter = xRemoteServiceManager.createInstanceWithContext(
"com.sun.star.comp.Writer.XMLImporter", xRemoteContext);
Object xmlStylesImporter = xRemoteServiceManager.createInstanceWithContext(
"com.sun.star.comp.Writer.XMLStylesImporter", xRemoteContext);
// get the interface of xmlexportfilter service
XImporter xImporter = (XImporter)UnoRuntime.queryInterface(XImporter.class, xmlImporter);

//XDocumentHandler xDocumentHandler =
// (XDocumentHandler)UnoRuntime.queryInterface(XDocumentHandler.class, xmlImporter);

XDocumentHandler xStyleHandler =
(XDocumentHandler)UnoRuntime.queryInterface(XDocumentHandler.class, xmlStylesImporter);

xImporter.setTargetDocument(newDoc);

Any help would be appreciated?

Re: Help with Style XML

Posted: Mon Jan 14, 2008 7:15 pm
by hol.sten
scottaf wrote:I'm writing some software in java to merge styles from one document to another
Sorry, but all I have is a question, because I never worked with XMLImporter or XMLStylesImporter in Java: Even if your merging of styles is possible, how will you handle styles that have the same name in both documents and don't have the same style settings? Wouldn't it be easier to use the well known style of one document and use them in both documents?

Re: Help with Style XML

Posted: Tue Jan 15, 2008 12:00 am
by scottaf
Ill have some external rules for that... The issue is actually that I am using an XML parser for dealing with the document and when I go to create a OO set of objects to bring the document
back in, it fails to import the styles for some reason. Perhaps Im using the wrong set of apis. Basically I have the document as a single stream of XML including all the office:* sections. Its not zipped and separated
into several files as in odt. Is there a simple means for bringing a document in this way?

Thanks for your thoughts.

Re: Help with Style XML

Posted: Tue Jan 15, 2008 8:09 am
by hol.sten
scottaf wrote:Is there a simple means for bringing a document in this way?
As far as I know, there is no such way.

If I had to deal with your problem, I would try to split the single stream of XML into separated files the way OOo does it, would zip them and open them the usual OOo loading documents way.

Re: Help with Style XML

Posted: Wed Jan 16, 2008 5:17 am
by scottaf
I did some more digging and it seems that the format I am looking to import is the Flat XML format. There used to be a Flat XML Filter but it is missing from its location in the dev project.
Has this been incorporated into the baseline now? Is there another way to import flat oasis XML?

Re: Help with Style XML

Posted: Wed Jan 16, 2008 11:57 pm
by hol.sten
scottaf wrote:Has this been incorporated into the baseline now? Is there another way to import flat oasis XML?
As far as I know, the answer to both of your questions is no.