XML Comment Feature
Are you missing a feature? Request its implementation here.
-
- Posts: 26
- Joined: Tue Mar 31, 2009 5:47 pm
XML Comment Feature
Hi guys,
I use the (Ctrl+Shift+,) shortcut to comment out selected XML all of the time. However, often I am wanting to comment out XML which already contains comments. Naturally this causes problems because in XML it is not possible to nest comments.
I think that it would be fantastic if this automatic comment feature toggled between the following (where the inner comment is automatically escaped and un-escaped):
Just an idea,
Many thanks,
Lea Hayes
I use the (Ctrl+Shift+,) shortcut to comment out selected XML all of the time. However, often I am wanting to comment out XML which already contains comments. Naturally this causes problems because in XML it is not possible to nest comments.
I think that it would be fantastic if this automatic comment feature toggled between the following (where the inner comment is automatically escaped and un-escaped):
Code: Select all
<my-node>
<!-- A comment. -->
<another-node/>
</my-node>
<!--<my-node>
<!-/- A comment. -/->
<another-node/>
</my-node>-->
Many thanks,
Lea Hayes
-
- Posts: 9420
- Joined: Fri Jul 09, 2004 5:18 pm
Re: XML Comment Feature
Hi Lea,
Indeed we know about this limitation when using the "Toggle Comments" operation and we'll probably try to fix it in a minor version of Oxygen 11.
Your suggested solution to escaping inner comments is indeed a good one and we'll probably use something very similar to what you proposed.
In the meantime, Oxygen offers support for creating your own custom actions and adding them to the contextual menu in the Text page so if you know Java you could implement your custom method to toggle comments.
For this you can read the Plugins section from
http://www.oxygenxml.com/developer.html
Regards,
Radu
Indeed we know about this limitation when using the "Toggle Comments" operation and we'll probably try to fix it in a minor version of Oxygen 11.
Your suggested solution to escaping inner comments is indeed a good one and we'll probably use something very similar to what you proposed.
In the meantime, Oxygen offers support for creating your own custom actions and adding them to the contextual menu in the Text page so if you know Java you could implement your custom method to toggle comments.
For this you can read the Plugins section from
http://www.oxygenxml.com/developer.html
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 26
- Joined: Tue Mar 31, 2009 5:47 pm
Re: XML Comment Feature
I have created the plugin, and it appears to work fine. It is a selection type plugin which shows up in the context menu.
How can I assign a keyboard shortcut to this plugin?
Preferably (Ctrl+Shift+,) because this is what I am used to.
Thanks,
Lea Hayes
How can I assign a keyboard shortcut to this plugin?
Preferably (Ctrl+Shift+,) because this is what I am used to.
Thanks,
Lea Hayes
-
- Posts: 9420
- Joined: Fri Jul 09, 2004 5:18 pm
Re: XML Comment Feature
Hi Lea,
Starting from Oxygen 10.3 (couple of weeks) you will have the ability to assign keyboard shortcuts to your custom plugin actions.
Here is the modification which you will have to perform to your plugin.xml file in order to assign shortcuts to the action:
In order to know what value to give to the keyboardShortcut attribute for a certain shortcut you can go to the Oxygen Preferences->Menu shortcut keys, press Edit for any shortcut and then get the string representation by pressing the desired shortcut.
Regards,
Radu
Starting from Oxygen 10.3 (couple of weeks) you will have the ability to assign keyboard shortcuts to your custom plugin actions.
Here is the modification which you will have to perform to your plugin.xml file in order to assign shortcuts to the action:
Code: Select all
<extension type="selectionProcessor"
class="your.package.ToggleComments" keyboardShortcut="ctrl shift COMMA"/>
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 26
- Joined: Tue Mar 31, 2009 5:47 pm
Re: XML Comment Feature
Excellent, I have adjusted the plugin XML file so that when I patch in a couple of weeks it is all up and running!
Here is the Java code of the plugin that I have created in case anyone else runs into this forum message:
Thanks Radu!
Lea Hayes
Here is the Java code of the plugin that I have created in case anyone else runs into this forum message:
Code: Select all
package custom.oxygen.plugin.comment;
import ro.sync.exml.plugin.selection.SelectionPluginContext;
import ro.sync.exml.plugin.selection.SelectionPluginExtension;
import ro.sync.exml.plugin.selection.SelectionPluginResult;
import ro.sync.exml.plugin.selection.SelectionPluginResultImpl;
public class ToggleCommentPluginExtension implements SelectionPluginExtension
{
public SelectionPluginResult process(SelectionPluginContext context)
{
if (context.getSelection().matches("\\s*\\<\\!-- (\\-?[^\\-])*--\\>\\s*"))
{
// Remove surrounding comment tags and un-escape any nested comments.
String removedComments = context.getSelection().replaceFirst("(\\s*)\\<\\!-- ((-?[^\\-])*) --\\>(\\s*)", "$1$2$4");
return new SelectionPluginResultImpl(removedComments.replaceAll("-\\\\-", "--"));
}
else
{
// Surround selection with comment tags and escape any nested comments.
return new SelectionPluginResultImpl("<!-- " + context.getSelection().replaceAll("--", "-\\\\-") + " -->");
}
}
}
Lea Hayes
-
- Posts: 9420
- Joined: Fri Jul 09, 2004 5:18 pm
Re: XML Comment Feature
Hi Lea,
Thanks for the code tip
We'll try to improve the in-editor "Toggle Comments" to take into account already existing comments in time for Oxygen 10.3 probably using the same escaping \ between the illegal -- that you suggested.
If this gets implemented, this will also be available on other Oxygen file types like CSS, JavaScript, SQL which also present multi-line comments.
Regards,
Radu
Thanks for the code tip

We'll try to improve the in-editor "Toggle Comments" to take into account already existing comments in time for Oxygen 10.3 probably using the same escaping \ between the illegal -- that you suggested.
If this gets implemented, this will also be available on other Oxygen file types like CSS, JavaScript, SQL which also present multi-line comments.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 6
- Joined: Thu Oct 25, 2018 7:14 pm
Re: XML Comment Feature
What ever happened with this request to be able to comment out XML content that includes some XML comments already?
___
On a related question: For some reason Toggle Comment is no longer enabled (menu Document > Edit > Toggle Comment or key Control+Shift_Comma). Dunno how that happened. How can I enable it again?
___
On a related question: For some reason Toggle Comment is no longer enabled (menu Document > Edit > Toggle Comment or key Control+Shift_Comma). Dunno how that happened. How can I enable it again?
-
- Posts: 9420
- Joined: Fri Jul 09, 2004 5:18 pm
Re: XML Comment Feature
Hi,
This forum thread is from 11 years ago, maybe you could have considered creating a new forum post.
About this question:
This works in the Text editing mode. I'm testing with Oxygen 23.0 but it's been working for quite a number of years. It does not work in the Author visual editing mode.
About your last question:
Regards,
Radu
This forum thread is from 11 years ago, maybe you could have considered creating a new forum post.
About this question:
In what editing mode are you editing your XML content? Text or Author?What ever happened with this request to be able to comment out XML content that includes some XML comments already?
This works in the Text editing mode. I'm testing with Oxygen 23.0 but it's been working for quite a number of years. It does not work in the Author visual editing mode.
About your last question:
It should be enabled if you have previously selected some content in the XML document.On a related question: For some reason Toggle Comment is no longer enabled (menu Document > Edit > Tog...
Regards,
Radu
Radu Coravu
<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