java vs javascript with Oxygen SDK

Post here questions and problems related to oXygen frameworks/document types.
msambasiva
Posts: 48
Joined: Tue Jul 17, 2018 6:57 am

java vs javascript with Oxygen SDK

Post by msambasiva » Wed Apr 29, 2020 5:33 am

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.

Radu
Posts: 7026
Joined: Fri Jul 09, 2004 5:18 pm

Re: java vs javascript with Oxygen SDK

Post by Radu » Wed Apr 29, 2020 7:39 am

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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

kirkilj
Posts: 101
Joined: Fri May 14, 2010 12:14 am

Re: java vs javascript with Oxygen SDK

Post by kirkilj » Sat May 16, 2020 11:20 pm

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?

Radu
Posts: 7026
Joined: Fri Jul 09, 2004 5:18 pm

Re: java vs javascript with Oxygen SDK

Post by Radu » Mon May 18, 2020 7:25 am

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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

kirkilj
Posts: 101
Joined: Fri May 14, 2010 12:14 am

Re: java vs javascript with Oxygen SDK

Post by kirkilj » Tue May 19, 2020 4:05 am

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?

Radu
Posts: 7026
Joined: Fri Jul 09, 2004 5:18 pm

Re: java vs javascript with Oxygen SDK

Post by Radu » Tue May 19, 2020 7:16 am

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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

kirkilj
Posts: 101
Joined: Fri May 14, 2010 12:14 am

Re: java vs javascript with Oxygen SDK

Post by kirkilj » Tue May 19, 2020 8:18 pm

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.

kirkilj
Posts: 101
Joined: Fri May 14, 2010 12:14 am

Re: java vs javascript with Oxygen SDK

Post by kirkilj » Tue May 19, 2020 11:46 pm

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.

Radu
Posts: 7026
Joined: Fri Jul 09, 2004 5:18 pm

Re: java vs javascript with Oxygen SDK

Post by Radu » Wed May 20, 2020 7:41 am

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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Post Reply