convert document on open

Oxygen general issues.
bueno
Posts: 2
Joined: Mon Jun 10, 2013 1:04 pm

convert document on open

Post by bueno »

We want Oxygen to automatically transform a xml document to another structure on opening it in Author.
After editing, on saving, Oxygen must then reconvert the document to its original structure.
How can we achieve this?
Radu
Posts: 9445
Joined: Fri Jul 09, 2004 5:18 pm

Re: convert document on open

Post by Radu »

Hi,

Could you elaborate a bit on the use-case?

One possibility would be to implement a custom protocol plugin using our Plugins SDK:

http://www.oxygenxml.com/oxygen_sdk.htm ... er_Plugins

The SDK contains a sample custom protocol implementation called "cproto" which wraps over existing local files and adds a special "Browse" action to the toolbar. So you could take a look at that.

Basically you would implement an URL Handler for URLs like "cproto://path/to/file.xml". When opening such an URL Oxygen would call you to obtain an input stream for it and when saving Oxygen would call you to save the edited content and you could save something else in the actual file.

Other possible alternatives:

Implement an Open Redirect plugin extension (sample also in the Plugins SDK). Basically when Oxygen would want to open the file from the local disk you could intercept that and request Oxygen to open a different file (for example a temporary file dynamically created by you in the same folder with the modified XML content). Then on save, if you implement a Workspace Access plugin type you could add a save listener on each opened editor and receive events that the document has been saved. Then you would take the content of the temporary file, convert it and save it over the original file.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
bueno
Posts: 2
Joined: Mon Jun 10, 2013 1:04 pm

Re: convert document on open

Post by bueno »

Hi Radu,
Thanks for your quick reply.

Basically users will:
a. browse a filesystem to select an existing xml document
b. create a new xml-document and save to filesystem.
In both cases, the xml content structure of the editable document is different from the document which is opened/saved, in order to maximize a userfriendly experience.

If I understand you correctly, there are several ways to achieve our goal.
I'll contact our developers and share your suggestions with them.

Regards,
Post Reply