XHTML Author Mode -- Empty tags / empty lines stripped

Having trouble installing Oxygen? Got a bug to report? Post it all here.
gwolfgang
Posts: 5
Joined: Mon Jan 28, 2008 1:17 am

XHTML Author Mode -- Empty tags / empty lines stripped

Post by gwolfgang »

OXYGEN 9.1 -- Build 2007122116

1) XHTML -- Empty tags stripped
When editing an XHTML document in Author mode, empty tags are automatically stripped when coming back to Text mode. In XHTML there are situations where you would need empty tags, for example when implementing rounded corners in a design using the formulation "<div class="background-corners"></div>, or when you want to link a background image <a href="mypage.html" class="background-imagelink"></a>. In both cases the background images are defined in a CSS file and the XHTML tag remains empty. For XHTML pages it is crucial to be able to keep empty elements expanded, otherwise the rendering will break in the browser.

2) XHTML -- Empty lines stripped
When editing an XHTML document in Author mode, all empty lines are automatically stripped away when coming back to Text mode. I would like my layout to be preserved the way I want, without automatic reformatting.

3) Options Menu
In the options menu I did not find a way to turn off empty tag and empty line stripping. It appears as if the available features in "Editor / Format / XML", namely "Preserve empty lines", "Keep text as it is" and "Expand empty elements" only influences the "Format and Indent" command while in Text mode, but does not influence the behavior of Oxygen XML in Author mode. Is this a bug, or did I ovelook something?

Please send me an answer as quickly as possible, since it may influence my decision to purchase Oxygen XML.

Thanks in advance,
Wolfgang
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Post by george »

Dear Wolfgang,

Indeed the serialization that is performed from the Author mode does not take into account all the format and indent options. I logged a bug on our issue tracking system to have this fixed.

If you want for a certain element to have its content preserved there are already two options. One is to add xml:space="preserve" on the specific element that you want to have the whitespace preserved. Another possibility is to add in the CSS file a property that specifies that the whitespace should be preserved, for instance:

white-space:pre;

The default CSS for XHTML is in oXygen/frameworks/xhtml/css/xhtml.css.

The visual editing mode is still new in oXygen, it was added starting with version 9.0 at the end of 2007. We are actively working on improving that and fixing any issues we or our users find.

Best Regards,
George
George Cristian Bina
gwolfgang
Posts: 5
Joined: Mon Jan 28, 2008 1:17 am

Post by gwolfgang »

George, thanks a lot for your very helpful infos!
gwolfgang
Posts: 5
Joined: Mon Jan 28, 2008 1:17 am

Post by gwolfgang »

George,

Short note on your suggestion:

Test
I tried using white-space:pre for the tags "div, h1-h6, p and a" in the setup file "oXygen/frameworks/xhtml/css/xhtml.css". A new problem seems to arise, namely that line wrapping no longer functions in Author Mode. Secondly, it does not solve the problem with tag stripping for empty elements. They are stripped as before.

Oxygen Updates
Do you think the empty element / empty line stripping bug correction will make it's way into version 9.2 already, or do I have to wait to version 10.0?
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Post by george »

Hi Wolfgang,

For the wrapping issue try using pre-wrap instead of pre:

white-space:pre-wrap;

The fix for looking at the format and indent property when serializing empty elements is scheduled to be solved in 9.2.

Best Regards,
George
George Cristian Bina
SteveB
Posts: 13
Joined: Sat Feb 02, 2008 6:52 pm

Re: XHTML Author Mode -- Empty tags / empty lines stripped

Post by SteveB »

I would like add another paragraph to the original post --

4) Indents and line breaks are added to text that is edited in Author mode upon return to Text mode.

The line breaks can be controlled by selecting "Preserve text as it is" in Preferences/Editor/Format/XML. But I can find no way to prevent the indents from being added.

We are experimenting with Oxygen to see how it might work as an editing tool in a magazine publishing workflow. We're editing and tagging text that will ultimately end up online and in print (via XSLT and Adobe InDesign's XML import features). The WYSIWYG appearance of Author mode could be a nice feature for editors who otherwise might not be comfortable working with XML.

For this to work, it's important that the file not get reformatted by the editing program. For example, all whitespace characters are read by InDesign when the files are imported -- so any unwanted indents show up and have to be dealt with. The workaround is to search for and delete them -- but it would be better to keep them from being added in the first place.

Please let me know if I'm overlooking something. Otherwise, here's hoping that this will be among the fixes in 9.2.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: XHTML Author Mode -- Empty tags / empty lines stripped

Post by sorin_ristache »

SteveB wrote:The line breaks can be controlled by selecting "Preserve text as it is" in Preferences/Editor/Format/XML. But I can find no way to prevent the indents from being added.
george wrote:The fix for looking at the format and indent property when serializing empty elements is scheduled to be solved in 9.2.
I assume you refer to indents added in the middle of text, for example an element

Code: Select all

<a>  text1
text2
</a>


is edited in Author mode and when you switch to Text mode it is reformatted to

Code: Select all

<a> text1 text2 </a>
which you do not want to happen. This should not happen when the option Preserve text as it is is on. As George pointed out the pretty print options (which include Preserve text as it is) will be applied in version 9.2 to the document when the switch from the Author mode to the Text mode occurs.

If this is not the case that you mean please give a specific example.


Regards,
Sorin
SteveB
Posts: 13
Joined: Sat Feb 02, 2008 6:52 pm

Re: XHTML Author Mode -- Empty tags / empty lines stripped

Post by SteveB »

Hi Sorin. Thank you for your response.

The problem actually has to do with all whitespace in the document. For example, this is how I would need an XML document to appear before importing into InDesign:

Code: Select all

<Root><story><p>First paragraph text text text text.</p>
<p>Second paragraph text text text text</p>
<p>And so forth.</p></story></Root>
There can be no whitespace between tags, except for newlines which must be placed only at the ends of paragraphs -- in other words, where they would occur in the printed document.

When moving from Author mode to Text mode, Oxygen "pretty prints" the file and adds indents and extra newlines in the process:

Code: Select all

<Root>
<story>
<p>First paragraph text text text text.</p>
<p>Second paragraph text text text text.</p>
<p>And so forth.</p>
</story>
</Root>
All of those additional newlines and spaces (or tabs) are considered significant by InDesign. Because they are inside the Root tag, the application reads them and formats them as part of the document. As a result you end up with all kinds of extra, unwanted whitespace that needs to be cleaned up.

It would be helpful to be able to disable all of this reformatting.

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

Re: XHTML Author Mode -- Empty tags / empty lines stripped

Post by sorin_ristache »

If you have to remove all whitespace from the document you have to add the attribute xml:space="preserve" to the Root element in the XML document or to specify white-space:pre for the Root element in the CSS stylesheet.

When you switch from Author to Text oXygen applies the pretty print options from preferences. In version 9.1 not all of them are applied but in the next version all the pretty print options will be applied. This is necessary for the readability of the source XML document. The whitespace added should not be important for other applications because the normalized version of the text is the same. If you have an application that requires having no whitespace between the tags you have to force that as I specified above.


Regards,
Sorin
SteveB
Posts: 13
Joined: Sat Feb 02, 2008 6:52 pm

Re: XHTML Author Mode -- Empty tags / empty lines stripped

Post by SteveB »

Sorin --

Adding a "white-space: pre-line" property to the CSS file did exactly what I was looking for. It preserves all of the line breaks but collapses all of the other whitespace. Perfect!

I would like to find a way to use formatted XML files with InDesign, but the application seems to insist on making every whitespace character significant. It does make the files more readable.

Thank you for your assistance.

Steve
ahab_2001
Posts: 3
Joined: Tue Mar 18, 2008 8:39 pm

Re: XHTML Author Mode -- Empty tags / empty lines stripped

Post by ahab_2001 »

sorin wrote:When you switch from Author to Text oXygen applies the pretty print options from preferences. In version 9.1 not all of them are applied but in the next version all the pretty print options will be applied. This is necessary for the readability of the source XML document. The whitespace added should not be important for other applications because the normalized version of the text is the same. If you have an application that requires having no whitespace between the tags you have to force that as I specified above.


Regards,
Sorin
If I could just request something here, I think that formatting and indenting when you pass from Author to Text needs to be made an option that the user can change from the preferences panel, the same way it is for when you pass from Grid to Text. There are some of us that would like our staff to be able to edit in a reasonably friendly authoring interface, but would still like to end up with the un-indented and un-line-broken XML that we started with for archival purposes. It seems odd that the program does this through a CSS change (which, it would seem to me, should only affect the way that the XML is rendered in the Authoring view, not in the source file), and I would ask that oXygen look at making this a selectable change in the preferences dialogue instead, as it is from grid to text.

Thanks,

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

Re: XHTML Author Mode -- Empty tags / empty lines stripped

Post by sorin_ristache »

ahab_2001 wrote:There are some of us that would like our staff to be able to edit in a reasonably friendly authoring interface, but would still like to end up with the un-indented and un-line-broken XML that we started with for archival purposes.
The normalized form of the XML document is the same. Only some whitespace characters are removed or added but this should not change the normalized form of the XML document. I think it should not change how the XML document is handled in XML processing applications.


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

Re: XHTML Author Mode -- Empty tags / empty lines stripped

Post by sorin_ristache »

There is an action on the contextual menu of the XML editor panel in Text mode, that is the action Join and Normalize in the Source submenu of the contextual menu that joins all elements of the current selection in a single line. Just select the whole XML document in the Text editor and press the shortcut of the action (by default Ctrl + J) to put all the document on a single line. You can change the shortcut of the action from Options -> Preferences -> Menu Shortcut Keys.

If you want to preserve the XML document in Text mode after the switch from Author mode to Text mode in the same format as before the switch you should add the attribute xml:space="preserve" to the root element of your document.


Regards,
Sorin
Post Reply