Set some DITA Key Definition Manager for different editors
-
- Posts: 61
- Joined: Tue Oct 27, 2015 11:49 am
Set some DITA Key Definition Manager for different editors
Post by Konstantin »
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);
}
}
How can I set KeyDefinitionManager for each editor.
-
- Posts: 517
- Joined: Thu Sep 04, 2014 4:22 pm
Re: Set some DITA Key Definition Manager for different editors
Post by cristi_talau »
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
-
- Posts: 61
- Joined: Tue Oct 27, 2015 11:49 am
Re: Set some DITA Key Definition Manager for different editors
Post by Konstantin »
I overrided
Code: Select all
public List<KeyDefinitionInfo> getContextKeyDefinitions(URL 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"

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);
}
-
- Posts: 517
- Joined: Thu Sep 04, 2014 4:22 pm
Re: Set some DITA Key Definition Manager for different editors
Post by cristi_talau »
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
-
- Posts: 61
- Joined: Tue Oct 27, 2015 11:49 am
Re: Set some DITA Key Definition Manager for different editors
Post by Konstantin »
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 {
....
}
}
-
- Posts: 517
- Joined: Thu Sep 04, 2014 4:22 pm
Re: Set some DITA Key Definition Manager for different editors
Post by cristi_talau »
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
-
- Posts: 61
- Joined: Tue Oct 27, 2015 11:49 am
Re: Set some DITA Key Definition Manager for different editors
Post by Konstantin »
-
- Posts: 61
- Joined: Tue Oct 27, 2015 11:49 am
Re: Set some DITA Key Definition Manager for different editors
Post by Konstantin »
I use this API for processing opening external and internal links: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.
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");
});
});
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>
<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 ?
-
- Posts: 517
- Joined: Thu Sep 04, 2014 4:22 pm
Re: Set some DITA Key Definition Manager for different editors
Post by cristi_talau »
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
-
- Posts: 61
- Joined: Tue Oct 27, 2015 11:49 am
Re: Set some DITA Key Definition Manager for different editors
Post by Konstantin »
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>
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
-
- Posts: 517
- Joined: Thu Sep 04, 2014 4:22 pm
Re: Set some DITA Key Definition Manager for different editors
Post by cristi_talau »
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
Best,
Cristian
-
- Posts: 61
- Joined: Tue Oct 27, 2015 11:49 am
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ Artificial Intelligence (AI Positron Assistant add-on)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service