Undo Pretty Print : the return

Oxygen general issues.
Gilles
Posts: 1
Joined: Sat May 02, 2009 12:17 pm

Undo Pretty Print : the return

Post by Gilles »

Hi,

I'm using Oxygen XMl Editor for a couple of years now, for PHP website development.

I recently changed my way of parsing XML documents in PHP and I'm now facing the well-know issue of tabs and spaces inserted into "pretty print" saved document formats, like this :

<?xml version="1.0" encoding="UTF-8"?>
<document>
__<element>one</element>
__<element>two</element>
</document>

So I would like to be able to easily "turn off" pretty print to obtain a "one single line" or "two lines" version like this :

<?xml version="1.0" encoding="UTF-8"?>
<document><element>one</element><element>two</element></document>

Someone asked the question about "undo pretty print" a long time ago :
http://www.oxygenxml.com/forum/topic1341.html

One of your answers stressed the difficulty to undo pretty print :
george wrote: If you look at the format and indent action as a function then that is not a bijective function, it will map any document X to a document Y but you cannot determine X if you know Y because there is a class of document {X1, X2, .... } that all will be mapped to Y so if you know Y you cannot determine which of these X1, X2, etc. was the initial document the format and indent was applied to.
I think that my case is more basic : I don't want to really "undo" what was done with pretty print, but rather produce a one single line (or two) saved version of the file, without any extra character than the pure XML content.

This is also best to reduce the size of the file on the web server, both to speed up its loading and ease its parsing.

I suppose that this can be achieved by some editor configuration, or by taking some other action in the editor (for example by always editing the file in "Grid" editor mode and not using pretty print anymore), but this is not entirely clear to me even after reading the Oxygen help.

Could you give me an advice about how to achieve this ?

Cheers,
Gilles.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Undo Pretty Print : the return

Post by sorin_ristache »

Hello,

Do you mean when you finished editing the XML document you want to apply Format and Indent and remove all whitespace nodes? This document formatting seems more connected with formatting to a machine (efficient) readable format than a human readable format as we intended this action. All the preferences of the Format and Indent action were added in Preferences -> Editor -> Format for making the result of the action more human readable, not machine readable. I think you should process your document with an XSLT stylesheet that removes all the empty (whitespace) nodes.


Regards,
Sorin
Post Reply