issue(possible bug) with XML templates and custom ID editor variable

Post here questions and problems related to oXygen frameworks/document types.
AndreasM
Posts: 10
Joined: Fri Nov 02, 2018 12:31 pm

issue(possible bug) with XML templates and custom ID editor variable

Post by AndreasM » Fri Mar 22, 2019 11:13 am

Hello,
we are using a framework template and a plugin (based on https://github.com/oxygenxml/wsaccess-j ... rVariables) to inject a custom server provided ID into the xml:id attribute of the root element when a new document is created. This works perfectly fine when creating a file using the menu "File/New..." but does not work as expected when I create a file via "right-click/New File" from within the data source explorer. In that case the filename ("untitled.xml" per default) overwrites the customID so I end up with xml:id="untitled" instead of my ID.

I narrowed down the issue to the option "Use the file name as the value of the root ID attribute" in "Preferences/DITA/New Topics". When I deactivate this option, the problem is resolved. Is this a bug? An option in the DITA settings should not influence the behaviour of generating XML files should it?. Automatically injecting the filename into the id attribute seems a strange default option. (tested this behaviour on version 20 and 21 of XML Editor)

Is there a way to deactivate this option for all users of my framework/plugin or would I have to ask them to do so manually ?

sorin_carbunaru
Site Admin
Posts: 248
Joined: Mon May 09, 2016 9:37 am

Re: issue(possible bug) with XML templates and custom ID editor variable

Post by sorin_carbunaru » Fri Mar 22, 2019 12:10 pm

Hello Andreas,

This is indeed a bug in oXygen... Fortunately, it has already been fixed in the current development sprint, and an oXygen 21 maintenance kit solving the issue will soon be available. We will update this thread when we release this kit.

If you cannot help until then, you could use the "ro.sync.exml.workspace.api.options.GlobalOptionsStorage.setGlobalObjectProperty(String, Object)" API method from any existing plugin. By the way, "PluginWorkspace" extends "GlobalOptionsStorage", and such an instance can be retrieved by calling "PluginWorkspaceProvider.getPluginWorkspace()". The key value for the "Use the file name as the value of the root ID attribute" option is "new.dita.topic.use.file.name.for.root.id".

A second method would be to create a plugin that is "specialized" in imposing option values, and which uses an XML configuration file. We have a sample called "oxygen-sample-plugin-impose-options" in the project that is created by following the procedure from https://www.oxygenxml.com/oxygen_sdk/download.html.

Depending on the chosen method, you can ask your users to update some already installed plugin, install a new one, or just wait for the oXygen maintenance kit.

All the best wishes,
Sorin Carbunaru
oXygen XML

sorin_carbunaru
Site Admin
Posts: 248
Joined: Mon May 09, 2016 9:37 am

Re: issue(possible bug) with XML templates and custom ID editor variable

Post by sorin_carbunaru » Wed Apr 03, 2019 9:43 am

Hello,

Just wanted to update this thread and let you know that am oXygen 21 maintenance kit has been released, and it contains a fix for the bug related to the "Use the file name as the value of the root ID attribute" option.

All the best wishes,
Sorin Carbunaru

AndreasM
Posts: 10
Joined: Fri Nov 02, 2018 12:31 pm

Re: issue(possible bug) with XML templates and custom ID editor variable

Post by AndreasM » Fri Apr 12, 2019 12:55 pm

Thank you!. Using the "setGlobalObjectProperty" function works. (Can't rely on the potential users installing the maintenance update :/ )

I have a related follow-up question though(if this is not the right place, I could start a new thread):
This method now creates an "untitled.xml" with my customID in the root Element. Is there any way I could also inject that customID into the file creation process in a way that the file would be created not as "Untitled.xml" (or whatever the user types in) but as "[my custom ID here].xml"? So when users create a file with our custom template the file should automatically get created in the correct path with the correct name. I have tried using the "EditorAboutToBeOpened" event listener with the saveAs function but naturally there was not "editor" that could be saved at this point.

sorin_carbunaru
Site Admin
Posts: 248
Joined: Mon May 09, 2016 9:37 am

Re: issue(possible bug) with XML templates and custom ID editor variable

Post by sorin_carbunaru » Mon Apr 15, 2019 2:24 pm

Hello Andreas,

Perhaps after getting notified by "ro.sync.exml.workspace.api.listeners.WSEditorChangeListener.editorOpened(URL)", you could call "ro.sync.exml.workspace.api.editor.WSEditorBase.saveAs(URL)" and set the desired name in the URL. If you want to find out if an editor was ever saved, you can call "ro.sync.exml.workspace.api.editor.WSEditorBase.isNewDocument()".

Sorin C.

Post Reply