Page 1 of 1

A way to compact XML files, to reverse indenting

Posted: Thu Nov 12, 2009 6:57 pm
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

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

Posted: Fri Nov 13, 2009 1:18 pm
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

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

Posted: Wed Nov 18, 2009 5:57 pm
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

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

Posted: Thu Nov 26, 2009 1:30 am
by anayram
Is there a way to remove the returns and tabs without having to use a search/replace Regex?

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

Posted: Thu Nov 26, 2009 11:06 am
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

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

Posted: Mon Nov 30, 2009 1:15 am
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

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

Posted: Mon Nov 30, 2009 11:29 am
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

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

Posted: Mon Nov 30, 2009 10:23 pm
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

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

Posted: Tue Dec 01, 2009 11:28 am
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

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

Posted: Thu Dec 03, 2009 6:38 am
by Michael_DC
Dear Radu,
This did the trick for me! Thanks a lot!

Best,
Michael