A way to compact XML files, to reverse indenting

Questions about XML that are not covered by the other forums should go here.
Michael_DC
Posts: 4
Joined: Thu Nov 12, 2009 6:24 pm

A way to compact XML files, to reverse indenting

Post by Michael_DC »

Hi,

Is there a way to compact XML files, to reverse indenting (an equivalent to BBEdit's Format:Compact)? In order to import Adobe XMP file into Acrobat all whitespace needs to be removed (AFAIK).

Michael
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: A way to compact XML files, to reverse indenting

Post by sorin_ristache »

Hello,

You can compact the text if you set a large line width for the Format and Indent action from menu Options -> Preferences -> Editor -> Format -- Line width and run the action Format and Indent. For example you can set the line width to 1,000 or 10,000 characters.


Regards,
Sorin
Michael_DC
Posts: 4
Joined: Thu Nov 12, 2009 6:24 pm

Re: A way to compact XML files, to reverse indenting

Post by Michael_DC »

sorin wrote:Hello,

You can compact the text if you set a large line width for the Format and Indent action from menu Options -> Preferences -> Editor -> Format -- Line width and run the action Format and Indent. For example you can set the line width to 1,000 or 10,000 characters.


Regards,
Sorin
Hello Sorin,

thanks for your help. This didn't remove the returns (CR/LF), though. As a workaround I used the Regex "(\n *)+?" search and replace to get the text compact.

Best,

Michael
anayram
Posts: 17
Joined: Wed Oct 28, 2009 8:35 pm

Re: A way to compact XML files, to reverse indenting

Post by anayram »

Is there a way to remove the returns and tabs without having to use a search/replace Regex?
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: A way to compact XML files, to reverse indenting

Post by sorin_ristache »

Hello,

Setting the line width for the Format and Indent action to a large value in Preferences -> Editor -> Format and running the action Format and Indent should remove the end of line characters by compacting the text lines according with the new line width. If an element name with the text lines that you want to compact does not have the attribute xml:space="preserve" and is not in the list Preserve space elements from Preferences -> Editor -> Format -> XML the text lines from that element are compacted on a single line. If the text is longer than the line width that was set in Preferences the Format and Indent action breaks the text by inserting an end of line at that line width.


Regards,
Sorin
Michael_DC
Posts: 4
Joined: Thu Nov 12, 2009 6:24 pm

Re: A way to compact XML files, to reverse indenting

Post by Michael_DC »

Hi Sorin,

I followed all your instructions regarding the setting of the preferences (Line width: 10000). Also, none of the elements is in the "Preserve space" list and still: no success,I'm afraid to say.

Best,

Michael
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: A way to compact XML files, to reverse indenting

Post by sorin_ristache »

Hello,

Please post a sample XML fragment here on the forum or send a sample XML file for reproducing the problem using the Technical Support form.


Thank you,
Sorin
anayram
Posts: 17
Joined: Wed Oct 28, 2009 8:35 pm

Re: A way to compact XML files, to reverse indenting

Post by anayram »

Hi Sorin,

I have also followed the instructions; no success either. If needed, I already sent a sample schema via the technical support form.

Cheers,
--
anayram
Radu
Posts: 9018
Joined: Fri Jul 09, 2004 5:18 pm

Re: A way to compact XML files, to reverse indenting

Post by Radu »

Dear Anayram,

Note that we had some technical problems and the sample you sent was not received.
Please send it to the following email address:
support@oxygenxml.com

There is another action that you may find useful to do the un-indent.
You can switch to the text page, select the XML content you want to normalize, right click, go to Source->Join and normalize

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Michael_DC
Posts: 4
Joined: Thu Nov 12, 2009 6:24 pm

Re: A way to compact XML files, to reverse indenting

Post by Michael_DC »

Dear Radu,
This did the trick for me! Thanks a lot!

Best,
Michael
Post Reply