Page 1 of 1

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

Posted: Fri Mar 22, 2019 11:13 am
by AndreasM
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 ?

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

Posted: Fri Mar 22, 2019 12:10 pm
by sorin_carbunaru
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

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

Posted: Wed Apr 03, 2019 9:43 am
by sorin_carbunaru
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

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

Posted: Fri Apr 12, 2019 12:55 pm
by AndreasM
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.

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

Posted: Mon Apr 15, 2019 2:24 pm
by sorin_carbunaru
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.