Reading and bootstrpping editor variables

Post here questions and problems related to oXygen frameworks/document types.
MarkusWittenberg
Posts: 2
Joined: Sun Jun 20, 2021 7:28 pm

Reading and bootstrpping editor variables

Post by MarkusWittenberg »

Hi,

Is there a way to just read the String values of (custom) editor variables from plugin or framework extension Java code, whithout any resolvers?

And on a related problem, can I set custom editor variables programmatically, e.g. for bootstrapping a standard value for the variable if it doesn't exist at the first loading time of a framework? Or is there another way to initialize them from framework files?

Best regards,
Markus
Radu
Posts: 8992
Joined: Fri Jul 09, 2004 5:18 pm

Re: Reading and bootstrpping editor variables

Post by Radu »

Hi Markus,

I'm not sure if I understand your question but we have Java API to expand editor variables in a string:

PluginWorkspaceProvider.getPluginWorkspace().getUtilAccess().expandEditorVariables(pathWithEditorVariables, currentEditedURL)

We also have APIs to add a custom editor variables resolver from a plugin:
PluginWorkspaceProvider.getPluginWorkspace().getUtilAccess().addCustomEditorVariablesResolver(resolver);

For example this sample javascript-based Oxygen plugin adds a custom editor variables resolver for a new ${clipboard} editor variable:
https://github.com/oxygenxml/wsaccess-j ... rVariables

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
MarkusWittenberg
Posts: 2
Joined: Sun Jun 20, 2021 7:28 pm

Re: Reading and bootstrpping editor variables

Post by MarkusWittenberg »

Hi Radu,

thanks for your response. I had seen the method UtilAccess.expandEditorVariables, but was confused by the URl context parameter and the API description "expand the editor variables in a path" as the editor variable's value is independent of the current editor URL in the use case and it could have another meaning than a path. So I tested it and it works fine.

But to the other question, setting the variable from code:
I want to use editor variables to set a base query path used in framework xpath_eval and oxy_path calls as well as in framework extension Java code. It should be an user adjustable constant, like an option. But as I haven't seen a way to use options in xpath_eval and oxy_path calls I decided to use custom editor variables instead.
But the framework should be deployed with a standard value of this custom editor variable. The custom editor variables resolver doesn't seem to provide this possibility. I know that I can set custom editor variables in a project's context. This works for a deployment of the framework as a project but not for a deployment as add-on. Or is there a way for the latter case? That's the reason way I searched for a way to set the custom editor variable programmatically if it is not set.

Best regards,
Markus
Radu
Posts: 8992
Joined: Fri Jul 09, 2004 5:18 pm

Re: Reading and bootstrpping editor variables

Post by Radu »

Hi Markus,

Some of our editor variables like ${cfd} - current file directory, depend on the current XML document and this is why the API has that second parameter which is useless in your case and can be given as "null".
From what I remember inside the xpath_eval editor variable you can use other editor variables, maybe a custom editor variable:
post60880.html?hilit=xpath_eval#p60876

About saving options at framework level, maybe you can create a file inside the framework folder containing a certain value and from the Java code read that file.
Or if you want a framework specific setting which can be changed by others and would be persisted by us between Oxygen runs, there is the API "AuthorAccess.getOptionsStorage()":

https://www.oxygenxml.com/InstData/Edit ... ccess.html

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply