Run dita-ot integrator transformation from custom oxygen plugin

Post here questions and problems related to oXygen frameworks/document types.
Lilipi
Posts: 3
Joined: Wed Dec 01, 2021 1:32 pm

Run dita-ot integrator transformation from custom oxygen plugin

Post by Lilipi »

Hi,

I would like to run "Dita-OT integrator" ant transformation from my custom java oxygen plugin.
It have to works on both Windows and Mac installations.
What's the best way to achieve this ?

I've seen that generated command by Oxygen is (on Windows) :

Code: Select all

"[path_to_oxygen]\Oxygen XML Editor 23\jre/bin/java" 
-Dfile.encoding=UTF-8 
-Xmx256m 
-Djava.awt.headless=true 
-classpath 
"[path_to_oxygen]\Oxygen XML Editor 23\tools\ant/lib/ant-launcher.jar" 
"-Dant.home=[path_to_oxygen]\Oxygen XML Editor 23\tools\ant" 
org.apache.tools.ant.launch.Launcher 
-lib "[path_to_oxygen]\Oxygen XML Editor 23\frameworks\dita\DITA-OT3.x\config" 
-lib "[path_to_oxygen]\Oxygen XML Editor 23\classes" 
-lib "[path_to_oxygen]\Oxygen XML Editor 23\lib\oxygenCommons.jar" 
-lib "[path_to_oxygen]\Oxygen XML Editor 23\lib\oxygen.jar" 
-lib "[path_to_oxygen]\Oxygen XML Editor 23\lib\oxygenAuthor.jar" 
-lib "[path_to_oxygen]\Oxygen XML Editor 23\lib\oxygenDeveloper.jar" 
-lib "[path_to_oxygen]\Oxygen XML Editor 23\lib\oxygenEclipse.jar" 
-lib "[path_to_oxygen]\Oxygen XML Editor 23\lib\oxygenAuthorEclipse.jar" 
-lib "[path_to_oxygen]\Oxygen XML Editor 23\lib\oxygenDeveloperEclipse.jar" 
-lib "[path_to_oxygen]\Oxygen XML Editor 23\lib\oxygen-basic-utilities.jar" 
-lib "[path_to_oxygen]\Oxygen XML Editor 23\lib\oxygen-sandbox.jar" 
-lib "[path_to_oxygen]\Oxygen XML Editor 23\lib\oxygen-editor-variables-parser.jar" 
-lib "[path_to_oxygen]\Oxygen XML Editor 23\lib\oxygen-patched-resolver.jar" 
-lib "[path_to_oxygen]\Oxygen XML Editor 23\lib\xml-apis.jar" 
-lib "[path_to_oxygen]\Oxygen XML Editor 23\lib\oxygen-patched-xerces.jar" 
-lib "[path_to_oxygen]\Oxygen XML Editor 23\lib\oxygen-patched-saxon-9.jar" 
-lib "[path_to_oxygen]\Oxygen XML Editor 23\lib\saxon9-sql.jar" 
-lib "[path_to_oxygen]\Oxygen XML Editor 23\lib\log4j-1.2-api-2.14.0.jar" 
-lib "[path_to_oxygen]\Oxygen XML Editor 23\lib\log4j-api-2.14.0.jar" 
-lib "[path_to_oxygen]\Oxygen XML Editor 23\lib\log4j-core-2.14.0.jar" 
-lib "[path_to_oxygen]\Oxygen XML Editor 23\frameworks\dita\DITA-OT3.x\plugins\com.oxygenxml.dost.patches\lib\oxygen-dost-patches.jar"
 -lib "[path_to_oxygen]\Oxygen XML Editor 23\frameworks\dita\DITA-OT3.x\lib\ant-apache-resolver-1.10.9.jar" 
 -lib "[path_to_oxygen]\Oxygen XML Editor 23\frameworks\dita\DITA-OT3.x\lib\ant-launcher.jar" 
 -lib "[path_to_oxygen]\Oxygen XML Editor 23\frameworks\dita\DITA-OT3.x\lib\ant.jar" 
 -lib "[path_to_oxygen]\Oxygen XML Editor 23\frameworks\dita\DITA-OT3.x\lib\commons-io-2.8.0.jar"
 -lib "[path_to_oxygen]\Oxygen XML Editor 23\frameworks\dita\DITA-OT3.x\lib\dost-configuration.jar" 
 -lib "[path_to_oxygen]\Oxygen XML Editor 23\frameworks\dita\DITA-OT3.x\lib\dost.jar"
 -lib "[path_to_oxygen]\Oxygen XML Editor 23\frameworks\dita\DITA-OT3.x\lib\guava-25.1-jre.jar" 
 -lib "[path_to_oxygen]\Oxygen XML Editor 23\frameworks\dita\DITA-OT3.x\lib\icu4j-69_1.jar"
 -lib "[path_to_oxygen]\Oxygen XML Editor 23\frameworks\dita\DITA-OT3.x\lib\isorelax-20030108.jar" 
 -lib "[path_to_oxygen]\Oxygen XML Editor 23\frameworks\dita\DITA-OT3.x\lib\jackson-annotations-2.11.0.jar" 
 -lib "[path_to_oxygen]\Oxygen XML Editor 23\frameworks\dita\DITA-OT3.x\lib\jackson-core-2.11.0.jar" 
 -lib "[path_to_oxygen]\Oxygen XML Editor 23\frameworks\dita\DITA-OT3.x\lib\jackson-databind-2.11.0.jar" 
 -lib "[path_to_oxygen]\Oxygen XML Editor 23\frameworks\dita\DITA-OT3.x\lib\jackson-dataformat-yaml-2.11.0.jar" 
 -lib "[path_to_oxygen]\Oxygen XML Editor 23\frameworks\dita\DITA-OT3.x\lib\jing-20181222.jar" 
 -lib "[path_to_oxygen]\Oxygen XML Editor 23\frameworks\dita\DITA-OT3.x\lib\logback-classic-1.2.3.jar" 
 -lib "[path_to_oxygen]\Oxygen XML Editor 23\frameworks\dita\DITA-OT3.x\lib\logback-core-1.2.3.jar" 
 -lib "[path_to_oxygen]\Oxygen XML Editor 23\frameworks\dita\DITA-OT3.x\lib\Saxon-HE-9.9.1-7.jar" 
 -lib "[path_to_oxygen]\Oxygen XML Editor 23\frameworks\dita\DITA-OT3.x\lib\slf4j-api-1.7.25.jar" 
 -lib "[path_to_oxygen]\Oxygen XML Editor 23\frameworks\dita\DITA-OT3.x\lib\snakeyaml-1.26.jar" 
 -lib "[path_to_oxygen]\Oxygen XML Editor 23\frameworks\dita\DITA-OT3.x\lib\xercesImpl-2.12.0.jar" 
 -lib "[path_to_oxygen]\Oxygen XML Editor 23\frameworks\dita\DITA-OT3.x\lib\xml-apis-1.4.01.jar" 
 -lib "[path_to_oxygen]\Oxygen XML Editor 23\frameworks\dita\DITA-OT3.x\lib\xml-resolver-1.2.jar"
 -f "[path_to_oxygen]\Oxygen XML Editor 23\frameworks/dita/DITA-OT3.x/integrator.xml" 
 "-Dstrict=true" 
 "-Dwebhelp.trial.license=no"

But it seems not really clean to run such a command line from my plugin. This command works if I run it in a windows command line.
What about Mac ?

Any help would be appreciated !
Thanks in advance
Radu
Posts: 7779
Joined: Fri Jul 09, 2004 5:18 pm

Re: Run dita-ot integrator transformation from custom oxygen plugin

Post by Radu »

Hi,

You did not give me details about what your java code looks like and what the obtain error when running the Java code was.

Anyway, the problem on Windows is that Oxygen may not have access rights to make changes to the "Program Files" folder where Oxygen gets installed by default. So running a Java process started from Oxygen will fail if Oxygen is installed in the "c:\Program Files" folder.

Maybe a better approach would be to create an Oxygen add-on which delivers an entire DITA Open Toolkit distribution (containing your extra plugins pre-installed) to users:
https://www.oxygenxml.com/doc/versions/ ... nsion.html

Coming back to your current approach, in the DITA OT "bin" folder "OXYGEN_INSTALL_DIR/frameworks/dita/DITA-OT3.x" there are two scripts one for Windows "dita.bat" and one for Linux/Mac named "dita". You can run the integrator on Windows with a command like this:

"dita.bat -i"

and on mac/linux with:

"sh dita -i"

So it's the equivalent of that larger command line Oxygen runs.

In Java there is a system property named "os.name" which gives you access to the operating system name on which Oxygen runs:
https://stackoverflow.com/questions/228 ... em-in-java

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Lilipi
Posts: 3
Joined: Wed Dec 01, 2021 1:32 pm

Re: Run dita-ot integrator transformation from custom oxygen plugin

Post by Lilipi »

Hi,

Thanks for your answer.
I didn't give errors or something else because I hadn't try it in practice. I was searching about how to do it first.

Between my post and your reply, I also found the dita script. I've tried it running the "install" command which is actually doing what I want. Great !

Therefore, I've got some new questions :
  • it seems that when we use "dita install" command when Oxygen is running, we have to restart it to take in account new plugins. Is that right ? Can we run another command after that to refresh data and avoid restart ?
  • If restart is mandatory, can we do it automatically without any action from user ?

Thanks a lot
Regards
Radu
Posts: 7779
Joined: Fri Jul 09, 2004 5:18 pm

Re: Run dita-ot integrator transformation from custom oxygen plugin

Post by Radu »

Hi,

About these questions:
it seems that when we use "dita install" command when Oxygen is running, we have to restart it to take in account new plugins. Is that right ? Can we run another command after that to refresh data and avoid restart ?
Oxygen usually goes through the DITA OT folder and collects the existing transformation types and their parameters after the default DITA OT location is changed in the Preferences->"DITA" page or after its bundled "Run DITA-OT integrator" transformation scenario is run.

Maybe from the plugin's code after running the integrator you could try to do something like this:

Code: Select all

    PluginWorkspaceProvider.getPluginWorkspace().setGlobalObjectProperty(OptionTags.DITA_OT_DIRECTORY, "abc");
    PluginWorkspaceProvider.getPluginWorkspace().setGlobalObjectProperty(OptionTags.DITA_OT_DIRECTORY, "${frameworksDir}/dita/DITA-OT3.x");
in order to force signal to Oxygen there was a change in the default dita ot folder used by it, so change the default DITA OT folder to some non existing path and then change it again to default.
If restart is mandatory, can we do it automatically without any action from user ?
I'm afraid we do not have APIs to restart Oxygen, if we did we'd also use this API in certain cases :) for example right after an add-on is installed we could restart Oxygen instead of instructing the end user to close and restart it.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Lilipi
Posts: 3
Joined: Wed Dec 01, 2021 1:32 pm

Re: Run dita-ot integrator transformation from custom oxygen plugin

Post by Lilipi »

Hi Radu,

Thanks a lot, it works like a charm !

Regards
Post Reply