Delete all the comments in one go in oXygen Author

Questions about XML that are not covered by the other forums should go here.
virals
Posts: 1
Joined: Thu Mar 28, 2019 1:55 pm

Delete all the comments in one go in oXygen Author

Post by virals »

Is there any way to delete all <!-- --> (XML comments) from an XML file(s) in one go?
mdslup
Posts: 167
Joined: Tue Mar 06, 2018 1:34 am

Re: Delete all the comments in one go in oXygen Author

Post by mdslup »

In text mode, you could use a regular expression to do a find/replace, like this:

https://i.imgur.com/Lf1oTSD.png

Check the "Regular expression" box in the bottom right. Then search for:"

<!--.*-->

and replace with nothing.
Radu
Posts: 9049
Joined: Fri Jul 09, 2004 5:18 pm

Re: Delete all the comments in one go in oXygen Author

Post by Radu »

Hi,

And if you want to remove all comments in one or multiple files, in the Oxygen main menu Tools->XML Refactoring there is a Delete comments operation which can be performed on multiple files.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Stereotaxis
Posts: 2
Joined: Thu Sep 26, 2019 3:50 pm

Re: Delete all the comments in one go in oXygen Author

Post by Stereotaxis »

Looking forward to see the suggestions of others.
Romaric
Posts: 3
Joined: Mon May 18, 2020 10:21 am

Re: Delete all the comments in one go in oXygen Author

Post by Romaric »

Hello, I read your messages about the tool : XML Refactoring > Delete comments but when I try to use it I don't understand how it's working.

May you tell me more about that ? Is there a tutorial or documentation ?

Best regards
Radu
Posts: 9049
Joined: Fri Jul 09, 2004 5:18 pm

Re: Delete all the comments in one go in oXygen Author

Post by Radu »

Hi,

We have some general documentation about the XML refactoring actions:

https://www.oxygenxml.com/doc/versions/ ... tools.html

but we do not have particular documentation about the action to delete comments.
Once you choose to use the "Delete comments" action, you need to configure an XPath expression for the XML elements from which the comments should be removed. If you want to delete all comments found in the XML file, the "Element" field can take the value *.
Then you choose a set of files over which should be modified and you can preview the changes instead of applying them directly.
If this does not work for you maybe you can tell me step by step what you are doing on your side and what the desired result should be.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Romaric
Posts: 3
Joined: Mon May 18, 2020 10:21 am

Re: Delete all the comments in one go in oXygen Author

Post by Romaric »

Thanks Radu for your answer,

I am not used to use XML and I don't know XPath but your advice with * works very well.

Now my XML file has many empty spaces or white lines.

Is there a way to delete those empty spaces or to avoid it when I use the tool ?

I would like a clean XML file.

(Sorry for my english I am french).

Thanks.

Regards
Radu
Posts: 9049
Joined: Fri Jul 09, 2004 5:18 pm

Re: Delete all the comments in one go in oXygen Author

Post by Radu »

Hi,

The refactoring operating which removes XML comments will not format and indent the XML document as a result of the XML comments being removed.
If you want to format and indent the XML files, you can either open them in Oxygen and use the "Format and indent" toolbar action or you can add in the Oxygen Project view a folder containing all the XML files, right click the folder and choose Format and indent files.

Regards,

Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply