Programmatically Adding Comments

Post here questions and problems related to oXygen frameworks/document types.
willy_mwangi
Posts: 3
Joined: Thu Feb 12, 2026 12:58 pm

Programmatically Adding Comments

Post by willy_mwangi »

I'm wondering whether there is an API available to allow a plugin to add a comment to a file programmatically. Any pointers will be highly apprectiated.
Radu
Posts: 9632
Joined: Fri Jul 09, 2004 5:18 pm

Re: Programmatically Adding Comments

Post by Radu »

Hi,
Can you elaborate on your request? What do you mean by comment? Do you mean an XML comment or a comment added similar to Oxygen's "Add comment" action? Do you have an existing Oxygen plugin or planning to build one?
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
willy_mwangi
Posts: 3
Joined: Thu Feb 12, 2026 12:58 pm

Re: Programmatically Adding Comments

Post by willy_mwangi »

I want to add a comment similar to Oxygen's "Add comment" action. I have an existing plugin.
Radu
Posts: 9632
Joined: Fri Jul 09, 2004 5:18 pm

Re: Programmatically Adding Comments

Post by Radu »

Hi,
Unfortunately we do not have such an API, if you want I can add an internal issue to consider adding it in a future version.
For now one would probably need as a workaround to:
(1) Create a document fragment from a range:
ro.sync.ecss.extensions.api.AuthorDocumentController.createDocumentFragment(int, int)
(2) Serialize the document fragment to XML:
ro.sync.ecss.extensions.api.AuthorDocumentController.serializeFragmentToXML(AuthorDocumentFragment)
(3) Delete the range from the document:
ro.sync.ecss.extensions.api.AuthorDocumentController.delete(int, int)
(4)
Modify the XML serialized from the fragment to add the processing instruction inside it.
(5)
Insert the XML fragment which now contains also the comment processing instructions inside the document:
ro.sync.ecss.extensions.api.AuthorDocumentController.insertXMLFragment(String, int)

I added an internal issue to provide APIs for adding comments in possibly a future Oxygen version, pasting the issue ID below for future reference:
EXM-56764 APIs to add comments programatically

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
willy_mwangi
Posts: 3
Joined: Thu Feb 12, 2026 12:58 pm

Re: Programmatically Adding Comments

Post by willy_mwangi »

Thank you for the response. Looking forward to seeing this capability in the SDK.
Post Reply