how to get the "keyref" attribute value
Post here questions and problems related to oXygen frameworks/document types.
-
- Posts: 140
- Joined: Fri Feb 28, 2020 4:02 pm
how to get the "keyref" attribute value
Post by vishwavaranasi »
Hello Team , we have a use case like this
1. Open a map in Author mode for editing
2. Select a topicref in the map, for example:
<topicref keyref="xxxx-639E21FB-6066-493B-A55E-xxxxxx" ... />
using java ..in my custom framworks , how to get the "keyref" attribute value?
Thanks,
vishwa
1. Open a map in Author mode for editing
2. Select a topicref in the map, for example:
<topicref keyref="xxxx-639E21FB-6066-493B-A55E-xxxxxx" ... />
using java ..in my custom framworks , how to get the "keyref" attribute value?
Thanks,
vishwa
Thanks,
vishwa
vishwa
-
- Posts: 73
- Joined: Wed Jun 22, 2016 2:48 pm
Re: how to get the "keyref" attribute value
Post by adrian_sorop »
Hi,
In order for me to provide a specific response I will require more information, like, for example a code snippet.
For now, here are some generic hints:
If you identified the node and it's an AuthorElement you can use the AuthorElement.getAttribute(attributeName) API - https://www.oxygenxml.com/InstData/Edit ... ement.html
If your node is not an AuthorElement you can check if the node is an instance of AuthorElement and, if the statement is true, cast it to AuthorElement and use the getAttribute API.
The getAttribute API returns an AttrValue - https://www.oxygenxml.com/InstData/Edit ... Value.html
Regards,
Adrian S
In order for me to provide a specific response I will require more information, like, for example a code snippet.
For now, here are some generic hints:
If you identified the node and it's an AuthorElement you can use the AuthorElement.getAttribute(attributeName) API - https://www.oxygenxml.com/InstData/Edit ... ement.html
If your node is not an AuthorElement you can check if the node is an instance of AuthorElement and, if the statement is true, cast it to AuthorElement and use the getAttribute API.
The getAttribute API returns an AttrValue - https://www.oxygenxml.com/InstData/Edit ... Value.html
Regards,
Adrian S
Adrian Sorop
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 140
- Joined: Fri Feb 28, 2020 4:02 pm
Re: how to get the "keyref" attribute value
Post by vishwavaranasi »
Hi Adrian , Thanks for the reply.
use case is when
1. Open a map in Author mode for editing
2. Select a topicref in the map, for example: <topicref keyref="xxxx-639E21FB-6066-493B-A55E-xxxxxx" ... />
and then my custom menu item from DITA is calling the the below custom class is from our custom frame work jar , we have attached a menu item from DITA -> and assigned the CustomOperation.java ..the menu item is invoking the class and it is printing currentRootMapURL.getFile(
BUT it is never entering addEditorChangeListener() method.
use case is when
1. Open a map in Author mode for editing
2. Select a topicref in the map, for example: <topicref keyref="xxxx-639E21FB-6066-493B-A55E-xxxxxx" ... />
and then my custom menu item from DITA is calling the the below custom class is from our custom frame work jar , we have attached a menu item from DITA -> and assigned the CustomOperation.java ..the menu item is invoking the class and it is printing currentRootMapURL.getFile(
BUT it is never entering addEditorChangeListener() method.
Code: Select all
public class CustomOperation implements AuthorOperation {
@Override
public void doOperation(AuthorAccess authorAccess, ArgumentsMap args) throws IllegalArgumentException, AuthorOperationException {
java.net.URL currentRootMapURL=ro.sync.ecss.dita.DITAAccess.getRootMapURL();
System.out.println("DefineKeysOperation--------doOperation"+currentRootMapURL.getFile());
JFrame oxygenFrame = (JFrame) authorAccess.getWorkspaceAccess().getParentFrame();
// it is never entering in to this method? addEditorChangeListener?
PluginWorkspaceProvider.getPluginWorkspace().addEditorChangeListener(new WSEditorChangeListener() {
public void editorSelected(URL editorLocation) {
try {
AuthorElement elem = (AuthorElement) authorAccess.getDocumentController().getNodeAtOffset(authorAccess.getEditorAccess().getCaretOffset());
System.out.println("DefineKeysOperation--------keyref 1 "+elem.getAttribute("keyref"));
AuthorNode authorNode=authorAccess.getDocumentController().getNodeAtOffset(authorAccess.getEditorAccess().getCaretOffset());
System.out.println("DefineKeysOperation--------keyref 2"+authorNode.getTextContent());
} catch (BadLocationException e) {
e.printStackTrace();
}
};
}, PluginWorkspace.MAIN_EDITING_AREA);
}
/**
* @return An array of {@link ArgumentDescriptor} representing
* the arguments this operation uses.
*/
@Override
public ArgumentDescriptor[] getArguments() {
return new ArgumentDescriptor[0];
}
/**
* @return The description of the extension.
*/
@Override
public String getDescription() {
return null;
}
}
Thanks,
vishwa
vishwa
-
- Posts: 73
- Joined: Wed Jun 22, 2016 2:48 pm
Re: how to get the "keyref" attribute value
Post by adrian_sorop »
Hi,
Let me know if I've undestood your use case correctly:
You open a ditamap in Author Page.
Then you select or click a node (a topicref).
Then you click this custom action that will invoke the custom author operation.
This action should print the value of the "keyref" attribute, if exists.
Try this:
Now, going to the second part:
In your code, every time the action was invoked, a new listener over the current document will be added. When the editor will be selected next time, will try to print the value of the keyref attribute.
So, I belive this is not the result you were expecting.
Regards,
Adrian S
Let me know if I've undestood your use case correctly:
You open a ditamap in Author Page.
Then you select or click a node (a topicref).
Then you click this custom action that will invoke the custom author operation.
This action should print the value of the "keyref" attribute, if exists.
Try this:
Code: Select all
@Override
public void doOperation(AuthorAccess authorAccess, ArgumentsMap args)
throws IllegalArgumentException, AuthorOperationException {
try {
int currentOffset = authorAccess.getEditorAccess().getCaretOffset();
AuthorNode nodeAtOffset = authorAccess.getDocumentController().getNodeAtOffset(currentOffset);
if (nodeAtOffset instanceof AuthorElement) {
AuthorElement authorElement = (AuthorElement) nodeAtOffset;
AttrValue keyrefAttrValue = authorElement.getAttribute("keyref");
if (keyrefAttrValue != null) {
System.out.println("keyref: " + keyrefAttrValue.getValue());
}
}
} catch (BadLocationException e) {
e.printStackTrace();
}
}
Here is the documentaion of the addEditorChangeListener(WSEditorChangeListener editorListener, int editingArea) API:BUT it is never entering addEditorChangeListener() method.
https://www.oxygenxml.com/InstData/Edit ... space.htmladdEditorChangeListener(WSEditorChangeListener editorListener, int editingArea)
Add listener for editor related events(for example editor opened, closed, page changed).
In your code, every time the action was invoked, a new listener over the current document will be added. When the editor will be selected next time, will try to print the value of the keyref attribute.
So, I belive this is not the result you were expecting.
Regards,
Adrian S
Adrian Sorop
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 140
- Joined: Fri Feb 28, 2020 4:02 pm
Re: how to get the "keyref" attribute value
Post by vishwavaranasi »
Thanks
it's worked ,but if i do the below , nodeAtOffset it is selecting the parent of selected tag
AuthorNode nodeAtOffset = authorAccess.getDocumentController().getNodeAtOffset(currentOffset);
or else if i do
AuthorNode nodeAtOffset = authorAccess.getDocumentController().getNodeAtOffset(currentOffset-1);
it is correctly shows the current selected tag
is this something expected?
it's worked ,but if i do the below , nodeAtOffset it is selecting the parent of selected tag
AuthorNode nodeAtOffset = authorAccess.getDocumentController().getNodeAtOffset(currentOffset);
or else if i do
AuthorNode nodeAtOffset = authorAccess.getDocumentController().getNodeAtOffset(currentOffset-1);
it is correctly shows the current selected tag
is this something expected?
Thanks,
vishwa
vishwa
-
- Posts: 73
- Joined: Wed Jun 22, 2016 2:48 pm
Re: how to get the "keyref" attribute value
Post by adrian_sorop »
Hi,
Here is the documentation regading the getNodeAtOffset(int) API - https://www.oxygenxml.com/InstData/Edit ... ffset-int-
Regards,
Adrian S.
Here is the documentation regading the getNodeAtOffset(int) API - https://www.oxygenxml.com/InstData/Edit ... ffset-int-
Regards,
Adrian S.
Adrian Sorop
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 140
- Joined: Fri Feb 28, 2020 4:02 pm
Re: how to get the "keyref" attribute value
Post by vishwavaranasi »
Thanks Adrian ,
am able to retrieve the selected "topicref" node "keyref" attribute value also this node has attribute "keys"
Now i have opened a dialog , and the dialog displayed 2 text fields
Keyref :
keys:
and this dialog has a button called "remove key" , means delete keys attribute and its value from the selected topicref
how can we dynamically this change can be applied to the target node?
Example 1: the selected <topicref keyref="keyref1234567" keys="key_to_title"/> from diamap
dialog displays the 2 values , with a button "remove key"
Keyref=keyref1234567
Keys=key_to_title
when use clicks remove key am adding action listener
i wanted do inside action listener , means delete keys attribute and its value from the selected topicref and the diamap should applied with the change and updated.
the selected should become this
<topicref keyref="keyref1234567"/>
am able to retrieve the selected "topicref" node "keyref" attribute value also this node has attribute "keys"
Now i have opened a dialog , and the dialog displayed 2 text fields
Keyref :
keys:
and this dialog has a button called "remove key" , means delete keys attribute and its value from the selected topicref
how can we dynamically this change can be applied to the target node?
Example 1: the selected <topicref keyref="keyref1234567" keys="key_to_title"/> from diamap
dialog displays the 2 values , with a button "remove key"
Keyref=keyref1234567
Keys=key_to_title
when use clicks remove key am adding action listener
i wanted do inside action listener , means delete keys attribute and its value from the selected topicref and the diamap should applied with the change and updated.
the selected should become this
<topicref keyref="keyref1234567"/>
Thanks,
vishwa
vishwa
-
- Posts: 73
- Joined: Wed Jun 22, 2016 2:48 pm
Re: how to get the "keyref" attribute value
Post by adrian_sorop »
Hi,
To remove an attribute and its values from a document use ro.sync.ecss.extensions.api.AuthorDocumentController.removeAttribute(String, AuthorElement).
Here is the documetation of this API: https://www.oxygenxml.com/InstData/Edit ... orElement-
Regards,
Adrian S.
To remove an attribute and its values from a document use ro.sync.ecss.extensions.api.AuthorDocumentController.removeAttribute(String, AuthorElement).
Here is the documetation of this API: https://www.oxygenxml.com/InstData/Edit ... orElement-
Regards,
Adrian S.
Adrian Sorop
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Return to “SDK-API, Frameworks - Document Types”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ 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