Access to ExtensionBundle from XSLT/Schematron

Post here questions and problems related to oXygen frameworks/document types.
Patrik
Posts: 228
Location: Hamburg/Germany

Access to ExtensionBundle from XSLT/Schematron

Tue Mar 25, 2014 9:25 am

Hi,

I've implemented an ExtensionBundle (derived from DITAExtensionsBundle) which - besides others - caches some data from the current book to be used in the styles filter, author operations, ...

Now I'd like to have access to this data from within my transformations and schematron validation as well (for better comfort and performance). Here I have the following problems:

  • I already implemented successfully a custom saxon extension for the xslt transformations. However, I can't get access to the cached data since although the caching class is a singleton a new (empty) instance is being created when called from xslt. Is there any way to access the existing instance?
  • I have no write access to the binary folder of oxygen. Thus, I can't place my saxon extension library there to make it available for the schematron validation. Is there already a way to explicitly configure an extension for schematron?

Thanks and regards

Patrik
Radu
Posts: 5876

Re: Access to ExtensionBundle from XSLT/Schematron

Tue Mar 25, 2014 10:18 am

Hi Patrik,

I already implemented successfully a custom saxon extension for the xslt transformations. However, I can't get access to the cached data since although the caching class is a singleton a new (empty) instance is being created when called from xslt. Is there any way to access the existing instance?


The extensions bundle works in a different isolated class loader so indeed static variables created in a specific class loader cannot be accessed from another.
To get into more details, the main Oxygen class loader loads all the libraries in the
OXYGEN\lib" folder. Then for each framework's extensions a separate class loader is created having as parent class loader the main Oxygen class loader.
One alternative would be to communicate objects using a library which is loaded in the main Oxygen class loader. For example on the extensions bundle side you could use:

Code: Select all

javax.swing.UIManager.getDefaults().put(key, value)


to put values in a static map, then from the XSLT code see if you can access by calling Java methods those keys in the "UIManager.getDefaults()" and read the values.
It depends on what type those values are, if they are plain strings or base Java types, it should work. If they are special objects created on the extensionsbundle class loader from classes defined in the JAR libraries added to the framework, you will have the same class loader issue.

I have no write access to the binary folder of oxygen. Thus, I can't place my saxon extension library there to make it available for the schematron validation. Is there already a way to explicitly configure an extension for schematron?


We already have an issue registered in our issues list to allow a Schematron-based validation scenario module to specify a set of JAR libraries to be used for validation. I will try to increase its priority.

Another approach for us to provide a fix for this kind of situations could be this one:

The validation scenario belongs to a certain document type and when the validation is performed using it we could use internally for validation (and including internal XSLT transformations) the same class loader which is created for that specific document type/framework (the same class loader which has loaded the extensions bundle instance). So we'll also investigate this approach.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Patrik
Posts: 228
Location: Hamburg/Germany

Re: Access to ExtensionBundle from XSLT/Schematron

Fri Mar 28, 2014 1:34 pm

Hi Radu,

thanks for the explanation.

I've split my library now and copied one part including the caching class to the oxygen/lib folder. Now everything works like a charm - even making complete nodes I already have cached available to schematron and xslt.

The trouble getting this lib installed among the team without admin privileges is definitely worth the benefit...

Regards

Patrik
Radu
Posts: 5876

Re: Access to ExtensionBundle from XSLT/Schematron

Fri Mar 28, 2014 1:59 pm

Hi Patrik,

We have plans to offer in a future version the support to contribute the JAR libraries from a plugin to the main Oxygen class loader (behave as if they would be in the Oxygen lib folder). I will let you know when we make this improvement.
One thing you could possibly do from your workspace access plugin would be to try to automatically copy the JAR from the plugin's lib folder to the "OXYGEN/lib" folder if it is not present there. You could also remember the file size of the last copied JAR so that when it changes in the add-on (the add-on gets updated), you can copy it again to the Oxygen lib folder.
After you copy the JAR you could show a message to the user to restart the application.
If the copying of the JAR fails you could show the user a message to call an admin and increase the rights on that particular folder or to install Oxygen some place else.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
tavy
Posts: 156

Re: Access to ExtensionBundle from XSLT/Schematron

Thu Oct 20, 2016 5:18 pm

Hi Patrik,

In oXygen 18.1 we added support in the validation scenario to specify extension JARs for the Schematron documents validation, and for the validation of XML documents against Schematron.

In the Specify Schema dialog box there is an Extensions button that opens a dialog box and allows you to specify Java extension JARs to be used during the validation:
https://www.oxygenxml.com/doc/versions/ ... nario.html

Best Regards,
Octavian
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com

Return to “SDK-API, Frameworks - Document Types”

Who is online

Users browsing this forum: No registered users and 5 guests