Set some DITA Key Definition Manager for different editors

Having trouble installing Oxygen? Got a bug to report? Post it all here.
Konstantin
Posts: 61
Joined: Tue Oct 27, 2015 11:49 am

Set some DITA Key Definition Manager for different editors

Post by Konstantin »

Hello
I use Webapp 18.0.0.3

I need resolve links like this:
<keyword keyref="keyword_context_variable_01"/>

For it I do:

Code: Select all

workspace.setDITAKeyDefinitionManager(keyDefManager);

Code: Select all

public class WorkspacePluginExtension implements WorkspaceAccessPluginExtension {

@Override
public void applicationStarted(final StandalonePluginWorkspace workspace) {

WSEditorChangeListener wsEditorChangeListener = new WSEditorChangeListener(){

@Override
public void editorAboutToBeOpened(URL url) {
super.editorOpened(url);

final String conKeys = Connection.sendAction(url, "getConKeys", null);
final DITAWorksKeyDefinitionManager keyDefManager = DITAWorksKeyDefinitionManager.createManager(conKeys, url);

[b]workspace.setDITAKeyDefinitionManager(keyDefManager);[/b]

final String editorUID = Util.getEditorUID(url.toString());
final EditorReference webappEditor = EditorReferenceManager.init(editorUID);
webappEditor.setKeyDefinitionManager(keyDefManager);
}
};

workspace.addEditorChangeListener(wsEditorChangeListener, PluginWorkspace.MAIN_EDITING_AREA);
}
}
It's work just for one editor, but I have many editors with different context maps.

How can I set KeyDefinitionManager for each editor.
cristi_talau
Posts: 496
Joined: Thu Sep 04, 2014 4:22 pm

Re: Set some DITA Key Definition Manager for different editors

Post by cristi_talau »

Hello,

The API you are using was designed for oXygen Author desktop and does not make much sense for Web Author which has multiple users. We have an issue registered to add an equivalent API that takes into account the multi-user scenario.

As a workaround you can use a global key definition manager and use the originatorURL parameter of the methods to identify the editor that requests the key. If you are opening files with the WebDAV plugin, the URL has the form webdav-http://session-id@host.com/path/to/file.xml. The same session ID is available to a WebappEditingSessionLifecycleListener [1] when the editor is opened.

Please let me know if this solves your use-case.

Best,
Cristian

[1] https://www.oxygenxml.com/InstData/Edit ... tener.html
Konstantin
Posts: 61
Joined: Tue Oct 27, 2015 11:49 am

Re: Set some DITA Key Definition Manager for different editors

Post by Konstantin »

Thanks it works.
I overrided

Code: Select all

public List<KeyDefinitionInfo> getContextKeyDefinitions(URL url)
and now take KeyDefinitions by editor url.

Also I have another problem.
My context variables resolved and showed in Author mode but they not valid
Validator write: "Key definition 'keyword_context_variable_01' not found in the DITA Map"

Image

Creating KeyDefinitionInfo:

Code: Select all

for (final KeyDefinitionElement element : list) {

final KeyDefinitionInfo info = new KeyDefinitionInfo();
final String query = url.getQuery();

final StringBuilder dwUrl = new StringBuilder();
dwUrl.append(Util.getBaseDwUrl(url));
dwUrl.append("sourceDocPath=null");
dwUrl.append(query.substring(query.indexOf("&clientId")));
dwUrl.append("&destDocPath=").append(element.getLocation());

final URL correct = CorrectURLUtil.correct(new URL(dwUrl .toString()));

info.setProperty(KeyDefinitionInfo.DEFINITION_LOCATION, correct);
info.setProperty(KeyDefinitionInfo.NAME, element.getName());
info.setProperty(KeyDefinitionInfo.HREF, element.getLocation());

....
keyDefinitions.add(info);
}
Where is problem and how can I change validation ?
cristi_talau
Posts: 496
Joined: Thu Sep 04, 2014 4:22 pm

Re: Set some DITA Key Definition Manager for different editors

Post by cristi_talau »

Hello,

I was able to reproduce your problem. It is a problem on our side. It will be fixed in a maintenance build for version 18.0, so it will be gone with the next update.

Best,
Cristian
Konstantin
Posts: 61
Joined: Tue Oct 27, 2015 11:49 am

Re: Set some DITA Key Definition Manager for different editors

Post by Konstantin »

Ok thanks, Will be waiting

And I have another question
In Oxygen applet we had opportunity to handle clicking by link (xref, keyword, ...):

Code: Select all


    final AuthorComponentFactory factory = AuthorComponentFactory.getInstance();

// Open a clicked link in the same component
factory.setOpenURLHandler(new OpenURLHandler() {

@Override
public void handleOpenURL(final URL url) throws IOException {
....
}
}
How can I do this now ?
cristi_talau
Posts: 496
Joined: Thu Sep 04, 2014 4:22 pm

Re: Set some DITA Key Definition Manager for different editors

Post by cristi_talau »

Hello,

We have some JS API with a similar effect [1]. You can modify the event fields to open a different URL, or you can call e.preventDefault() and do something else.

Please let me know if this solves your use case.

Best,
Cristian

[1] https://www.oxygenxml.com/maven/com/oxy ... Event.html
Konstantin
Posts: 61
Joined: Tue Oct 27, 2015 11:49 am

Re: Set some DITA Key Definition Manager for different editors

Post by Konstantin »

Thanks, It helped.
Konstantin
Posts: 61
Joined: Tue Oct 27, 2015 11:49 am

Re: Set some DITA Key Definition Manager for different editors

Post by Konstantin »

cristi_talau wrote: We have some JS API with a similar effect [1]. You can modify the event fields to open a different URL, or you can call e.preventDefault() and do something else.
I use this API for processing opening external and internal links:

Code: Select all

goog.events.listen(editor, sync.api.Editor.EventTypes.LINK_OPENED, function(e) {

if (e.external === true) {
return;
}

e.preventDefault();

openLink(e, function() {
console.log("LINK_OPENED");
});
});
My links:

Code: Select all


            <xref href="source_01.dita#id_1/p_topic_body_p_2"/>
<xref keyref="xrefKeyref/p_topic_body_p_3"/>
<keyword keyref="keyword_context_variable_01"/>
<p conkeyref="chunk_context_text_block_01/p_topic_body_p_5_1"/>
<p conref="source_01.dita#id_1/p_topic_body_p_4"/>

<link format="html" href="http%3A%2F%2Fditaworks.com" scope="external">
<linktext>DITA CMS for enterprise content solutions </linktext>
</link>
All work right expect:
<xref keyref="xrefKeyref/p_topic_body_p_3"/>

e.external for this link came as external but must be internal

Is it bug or no ?
cristi_talau
Posts: 496
Joined: Thu Sep 04, 2014 4:22 pm

Re: Set some DITA Key Definition Manager for different editors

Post by cristi_talau »

Hello,

We have a heuristic that decide whether a link is considered internal or external. So, it may be wrong in some cases. I would need some more information to be able to reproduce your scenario:
1. The link icon has an ancestor div with data-external="true". This element also has an attribute data-url. What is the value of this attribute?
2. What is the URL of the opened document that you passed to Web Author?

Best,
Cristian
Konstantin
Posts: 61
Joined: Tue Oct 27, 2015 11:49 am

Re: Set some DITA Key Definition Manager for different editors

Post by Konstantin »

All topic:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<topic id="id_1" xmlns:ditaarch="http://dita.oasis-open.org/architecture/2005/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:oasis:names:tc:dita:xsd:topic.xsd">
<title>Topic tis<i>l</i>
</title>
<body>
<p>
<xref href="source_01.dita#id_1/p_topic_body_p_2"/>
</p>
<p>
<xref keyref="xrefKeyref/p_topic_body_p_3"/>
</p>
<p>
<keyword keyref="keyword_context_variable_01"/>
</p>
<p conkeyref="chunk_context_text_block_01/p_topic_body_p_5_1"/>
<p conref="source_01.dita#id_1/p_topic_body_p_4"/>
<p>
<link format="html" href="http%3A%2F%2Fditaworks.com" scope="external">
<linktext>DITA CMS for enterprise content solutions </linktext>
</link>
</p>
</body>
</topic>
Only LINK must be external here, but also external <xref keyref="xrefKeyref/p_topic_body_p_3"/>
URL in xref: http://localhost:8888/Folder/path/sourc ... c_body_p_3

Current document URL:

Code: Select all

dw://AD1B52B108ABC1A062758D37F3133ED3@localhost:8888/webapp_editor?sourceDocPath=/Folder/path/topic_conref.dita&clientId=1468222376444&editorUID=7e31971a-0a17-4438-939c-9d0dd6d13a5b&isReadOnly=false&username=zo&isDitry=false
cristi_talau
Posts: 496
Joined: Thu Sep 04, 2014 4:22 pm

Re: Set some DITA Key Definition Manager for different editors

Post by cristi_talau »

Hello,

I managed to reproduce your problem. I will fix it for the next release.

However, for the moment you can try to make the URL used in xref resolve to something like:

Code: Select all

dw://localhost:8888/Folder/path/source_01.dita#[ANY]/p_topic_body_p_3
This is interpreted better by our heuristics at the moment.

Best,
Cristian
Konstantin
Posts: 61
Joined: Tue Oct 27, 2015 11:49 am

Re: Set some DITA Key Definition Manager for different editors

Post by Konstantin »

Ok. Thanks
Post Reply