Page 1 of 1

java vs javascript with Oxygen SDK

Posted: Wed Apr 29, 2020 5:33 am
by msambasiva
Hi,

As I understand, we can use either java or javascript with SDK to customize the Oxygen features. Please correct me if I am wrong. I am basically a java developer. Please let me know if I need to learn javascript to work with Oxygen SDK. If required, can we use javascript framework with Oxygen SDK? If so, which is the best framework?

Please suggest any reference to read to get started with schematron in Oxygen.

Thanks,
Samba.

Re: java vs javascript with Oxygen SDK

Posted: Wed Apr 29, 2020 7:39 am
by Radu
Hi Samba,

Javascript is an alternative when it comes to creating small Oxygen plugins. A Javascript-based plugin can call our Java API:

https://www.oxygenxml.com/doc/versions/ ... in-js.html

But there is no option to use Javascript to developer framework customizations, it's only available for plugins.

So as you are comfortable with Java you should continue using it.

About Schematron, besides Oxygen's user's manual there are a couple of topics on the Oxygen XML Blog:

https://blog.oxygenxml.com/topics/shari ... rules.html
https://blog.oxygenxml.com/topics/SchematronBCs.html

If you want to learn Schematron, you can google for Schematron tutorials, there is also a tutorial with samples created by my colleague Octavian:

https://github.com/octavianN/Schematron-step-by-step

Regards,
Radu

Re: java vs javascript with Oxygen SDK

Posted: Sat May 16, 2020 11:20 pm
by kirkilj
Hi Radu,

I'm having trouble reconciling the two statements below:
Radu wrote: Wed Apr 29, 2020 7:39 am Javascript is an alternative when it comes to creating small Oxygen plugins. A Javascript-based plugin can call our Java API:

But there is no option to use Javascript to developer framework customizations, it's only available for plugins.
is this because we can't add JavaScript assets to the Extensions tab of a framework?

Re: java vs javascript with Oxygen SDK

Posted: Mon May 18, 2020 7:25 am
by Radu
Hi John,

Right, the Extensions tab for a framework customization only allows JAR libraries in the classpath. We might add some day for Javascript-based extensions here but right now only Java can be used for framework extensions.

Regards,
Radu

Re: java vs javascript with Oxygen SDK

Posted: Tue May 19, 2020 4:05 am
by kirkilj
I understand.

Are you thinking that one option might be to have a wrapper jar that can pick up a directory of Javascript assets in the framework directory?

Re: java vs javascript with Oxygen SDK

Posted: Tue May 19, 2020 7:16 am
by Radu
Hi John,

If we were to look into implementing this, we could possibly look in all folder in the framework configuration's classpath, load all Javascript files having a particular name pattern using the Rhyno library we already use for plugins, then from those Javascript files call some methods to return implementations of those classes. But I do not have all the details figured out for this one.

Regards,
Radu

Re: java vs javascript with Oxygen SDK

Posted: Tue May 19, 2020 8:18 pm
by kirkilj
Hi Radu,
But I do not have all the details figured out for this one.
What!!! Not yet??? ;)

Btw, we had one of our student interns write our first instances of Java extensions, which still need some work before including it in our framework.
  1. Support multiple ID generation patterns, each having their own list of elements. Right now, Oxygen supports just one pattern and one element list. We don't want our users to be able to configure this with a dialog box though. Our Information Architecture group has defined the patterns they want to use for different groups of elements.
    • Is there a hook to have the Generate IDs execute our own code instead of the default code?
    • Can we suppress the built-in ID Options dialog?
  2. A Build Log Viewer in a JTable that supports filtering. It also shows the full text of the log in a sibling panel and positions the viewable area of that panel depending on the currently selected row in the table so that it shows the context of the error. We plan on adding regex support and the ability to offer named regex filters and selectors for different uses, such as error severity level, component (build.xml, DITA-OT, FOP, etc.), error code, ditamap for multi ditamap builds, etc.
Unfortunately, that particular student graduated, so someone else will need to work on the UX and features a bit more. It's still exciting though to finally have this customization capability in our grasp.

If time allowed, I was going to ask her to implement JavaScript versions as well for example purposes, but now that I know we can't include them in a framework, there's no need.

Re: java vs javascript with Oxygen SDK

Posted: Tue May 19, 2020 11:46 pm
by kirkilj
Hi Radu,

It looks like Rhino has a compiler and debugger: https://developer.mozilla.org/en-US/doc ... t_Compiler

From the above page:
The JavaScript compiler translates JavaScript source into Java class files. The resulting Java class files can then be loaded and executed at another time, providing a convenient method for transferring JavaScript, and for avoiding translation cost.

Re: java vs javascript with Oxygen SDK

Posted: Wed May 20, 2020 7:41 am
by Radu
Hi John,

About these questions:
Is there a hook to have the Generate IDs execute our own code instead of the default code?
Sure, actually you can do this quite easily by editing the DITA extension framework configuration and in the "Author->Actions" tab find the action for "generate.ids" and have it call a custom operation (even JSOperation).
Can we suppress the built-in ID Options dialog?
This is again an action with id "id.options" defined in the Actions list. You can remove it from the menus and toolbars.
A Build Log Viewer in a JTable that supports filtering. It also shows the full text of the log in a sibling panel and positions the viewable area of that panel depending on the currently selected row in the table so that it shows the context of the error. We plan on adding regex support and the ability to offer named regex filters and selectors for different uses, such as error severity level, component (build.xml, DITA-OT, FOP, etc.), error code, ditamap for multi ditamap builds, etc.
So some user interface in which you load the entire DITA OT console output and tries to present in a structured form the encountered errors? This is similar to what we do, we present in the Problems view errors gathered from the DITA OT console output.

About using Javascript for extensions, in my opinion it's nice to use when you have small pieces of code but as the code gets larger and you call lots of APIs on the Oxygen side, for me it's easier using Java, you get clear compilation errors if you make mistakes, I get content completion when calling various APIs on the Oxygen side so I don't need to look at the Oxygen SDK Javadoc just to see what methods are available in what object.

Regards,
Radu