Author actions when cursor is in a comment
Having trouble installing Oxygen? Got a bug to report? Post it all here.
-
- Posts: 93
- Joined: Fri Mar 08, 2013 8:58 am
Author actions when cursor is in a comment
Hi,
I've tried a simple Author MoveCaretOperation to move the cursor to ancestor-or-self::*[1]. It works fine, except when the cursor is currently in a comment or processing instruction. In those cases the action does not start. I've found some other author actions that seem not to respond when the cursor is in a comment or processing instruction. Is this a feature or a bug? Are there workarounds? (I had hoped a simple MoveCaretOperation would be provide that workaround.)
I've tried a simple Author MoveCaretOperation to move the cursor to ancestor-or-self::*[1]. It works fine, except when the cursor is currently in a comment or processing instruction. In those cases the action does not start. I've found some other author actions that seem not to respond when the cursor is in a comment or processing instruction. Is this a feature or a bug? Are there workarounds? (I had hoped a simple MoveCaretOperation would be provide that workaround.)
-
- Posts: 78
- Joined: Wed Jun 22, 2016 2:48 pm
Re: Author actions when cursor is in a comment
Post by adrian_sorop »
Hi!
Try to use node():
* matches only element nodes.
node() matches comments, processing instructions and text nodes.
Hope it helps,
Adrian S.
Try to use node():
Code: Select all
ancestor-or-self::node()[1]
node() matches comments, processing instructions and text nodes.
Hope it helps,
Adrian S.
Adrian Sorop
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 78
- Joined: Wed Jun 22, 2016 2:48 pm
Re: Author actions when cursor is in a comment
Post by adrian_sorop »
Hi again.
Now I sow that you had other issue:
The simplest way is to force the action be te enabled all the time: go to action's dialog box and set operation's Activation Xpath to "true()".
Regards,
Adrian S
Now I sow that you had other issue:
I suppose the action it's not enabled for processing intructions.It works fine, except when the cursor is currently in a comment or processing instruction. In those cases the action does not start.
The simplest way is to force the action be te enabled all the time: go to action's dialog box and set operation's Activation Xpath to "true()".
Regards,
Adrian S
Adrian Sorop
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 93
- Joined: Fri Mar 08, 2013 8:58 am
Re: Author actions when cursor is in a comment
Hm, this is strange.
In a dummy project file, I have my cursor in a comment, XPath /root/a/b/comment(). I have a simple author action, to move to the current parent. I've adopted your suggested ancestor-or-self::node()[1] (though I'm not sure why I need to make this change -- ancestor-or-self::*[1] works fine in the Oxygen XPath/XQuery Builder when the context is a comment). I've added the XPath activation true(). (That feels like a hack -- shouldn't a blank value allow the action to be applicable whenever, wherever?)
Those settings finally get a response, but it selects the root element, not the parent! Same thing happens when [last()] is substituted for [1]. When the cursor is in an element or text node the behavior is as expected.
In a dummy project file, I have my cursor in a comment, XPath /root/a/b/comment(). I have a simple author action, to move to the current parent. I've adopted your suggested ancestor-or-self::node()[1] (though I'm not sure why I need to make this change -- ancestor-or-self::*[1] works fine in the Oxygen XPath/XQuery Builder when the context is a comment). I've added the XPath activation true(). (That feels like a hack -- shouldn't a blank value allow the action to be applicable whenever, wherever?)
Those settings finally get a response, but it selects the root element, not the parent! Same thing happens when [last()] is substituted for [1]. When the cursor is in an element or text node the behavior is as expected.
-
- Posts: 78
- Joined: Wed Jun 22, 2016 2:48 pm
Re: Author actions when cursor is in a comment
Post by adrian_sorop »
So,
In the code of the operation, this metod si called with all the boolean parameters on true. This means that comments, text nodes and CData are ignored.
I've logged an issue to reconsider this behaviour
The XPath expression equivalent of the empty field is:.
If you want, you can change the Activation XPath to something like
but I don't like, that's why I recommanded the true() funtion. The result should be the same.
Anyways, as far as I understood, I think that ancestor axe should not be used with last(). You can try something like self::node()[last()]
The MoveCaretOperation uses the following API ro.sync.ecss.extensions.api.AuthorDocumentController.findNodesByXPath(String, boolean, boolean, boolean) to detect the nodes from the xpath.I've adopted your suggested ancestor-or-self::node()[1] (though I'm not sure why I need to make this change -- ancestor-or-self::*[1] works fine in the Oxygen XPath/XQuery Builder[...]
Code: Select all
/**
*Finds the author nodes selected by the given XPath 2.0 expression.
*
* @param xpathExpression The XPath expression. If the XPath expression is relative, it will be computed in the context of the current caret position.
* @param ignoreTexts If <code>true</code> Author text nodes will not be returned.
* @param ignoreCData If <code>true</code> Author CDATA sections will not be returned.
* @param ignoreComments If <code>true</code> Author comments will not be returned.
*/
AuthorNode[] findNodesByXPath(String xpathExpression, boolean ignoreTexts, boolean ignoreCData, boolean ignoreComments)
I've logged an issue to reconsider this behaviour
The Activation XPath is documented asI've added the XPath activation true(). (That feels like a hack -- shouldn't a blank value allow the action to be applicable whenever, wherever?)
. This means that it takes into account elements only.An XPath 2.0 expression that applies to elements and attributes.
The XPath expression equivalent of the empty field is:
Code: Select all
boolean(self::*)
If you want, you can change the Activation XPath to something like
Code: Select all
boolean(self::node())
I don't think I fully understand this case. Perhaps a small example would be usefull.Same thing happens when [last()] is substituted for [1]. When the cursor is in an element or text node the behavior is as expected.
Anyways, as far as I understood, I think that ancestor axe should not be used with last(). You can try something like self::node()[last()]
Adrian Sorop
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 93
- Joined: Fri Mar 08, 2013 8:58 am
Re: Author actions when cursor is in a comment
So given the following author action, "move_to_parent"...
...and given the following XML...
...when in Oxygen Author the cursor is in the text node of <b> or in the processing-instruction or in the CDATA, then each time "move_to_parent" is run <b> is selected, as expected. But when the cursor is in the comment and "move_to_parent" is run, <a> is selected, which is of course unexpected.
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<a:authorAction xmlns:a="http://www.oxygenxml.com/ns/author/external-action"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.oxygenxml.com/ns/author/external-action http://www.oxygenxml.com/ns/author/external-action/authorAction.xsd"
id="move-to-parent">
<a:name>move to parent</a:name>
<a:description>Move to parent element</a:description>
<a:operations>
<a:operation id="MoveCaretOperation">
<a:xpathCondition>true()</a:xpathCondition>
<a:arguments>
<a:argument name="selection">Element</a:argument>
<a:argument name="xpathLocation">ancestor-or-self::node()[1]</a:argument>
</a:arguments>
</a:operation>
</a:operations>
<a:accelerator>M3 5</a:accelerator>
<a:enabledInReadOnlyContext>false</a:enabledInReadOnlyContext>
</a:authorAction>
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<a>text
<b>text
<!-- comment --><?test?><![CDATA[test]]>
</b>
</a>
-
- Posts: 78
- Joined: Wed Jun 22, 2016 2:48 pm
Re: Author actions when cursor is in a comment
Post by adrian_sorop »
Yes, you're right.
I've added your feedback to the issue.
This behaviour will be fixed in the following release.
Thanks!
I've added your feedback to the issue.
This behaviour will be fixed in the following release.
Thanks!
Adrian Sorop
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
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