Page 1 of 1

How can I prevent whitespace between elements when inserting via an action in Oxygen Author Mode?

Posted: Mon Apr 12, 2021 10:33 am
by Jolanda
Hello,

How can I prevent whitespace between elements when inserting via an action in Oxygen Author Mode?
I want to insert

Code: Select all

<e1><e2/></e1>
via the action, without spaces between the elements. However, when I execute the corresponding action in text mode, it looks like this:

Code: Select all

<e1> <e2/> </e1>
. What can I do to prevent the spaces?

Many greetings
Jolanda

Re: How can I prevent whitespace between elements when inserting via an action in Oxygen Author Mode?

Posted: Mon Apr 12, 2021 11:41 am
by Radu
Hi Jolanda,

Could you give us some details about how you have set up that action? Did you set up as an action specific to the Author visual editing mode in the framework associated to your XML document? If so what operation does the action invoke and with what parameters?
About the element "<e1>", does it allow text content inserted directly inside it or is it element only?
You mentioned:
However, when I execute the corresponding action in text mode,
Did you mean that you execute the action in the Author visual mode and then look in the Text mode to see what's inserted? Or does the custom action also work in the Text mode? If so, how did you set it up?

Regards,
Radu

Re: How can I prevent whitespace between elements when inserting via an action in Oxygen Author Mode?

Posted: Mon Apr 12, 2021 1:45 pm
by Jolanda
Hi Radu,

thanks for the answer. I have set up the action in a framework connected to my XML document and the action is run in author mode and I then look at it in text mode, which is when the spaces are visible. The <e1> element remains empty and only contains the <e2> element.

The operation:
ro.sync.ecss.extensions.commons.operations.InsertFragmentOperation

The paramater:
fragment: <e1><e2>[TEXT]</e2></e1>
InsertLocation: [Empty]
InsertPosition: Inside as first child
schemaAware: true
goToNextEditablePosition: true

Regards,
Jolanda

Re: How can I prevent whitespace between elements when inserting via an action in Oxygen Author Mode?

Posted: Mon Apr 12, 2021 2:10 pm
by Radu
Hi Jolanda,

And how does the XML element look like in the Text editing mode?
Does it look like this?

Code: Select all

<e1>
   <e2>[TEXT]</e2>
 </e1>
 
When the content edited in the Author visual editing mode gets serialized to XML, for each XML element Oxygen tries to decide if its contents are element-only (like in the case of your "e1" element) or if it also allows text content.
For this Oxygen looks in the associated schema. If the element has element-only content, Oxygen decides that it can add indentation and new lines inside it because that extra indentation will not change its contents. We add that indentation because the serialized XML document needs to be human readable.

We have a topic in our user's manual about Author serialization to XML:
https://www.oxygenxml.com/doc/versions/ ... dling.html

Other than that, is that "e1" element an inline element (appears in a paragraph along other inline elements and text) or is it a block level element (like a paragraph or a table)?
Do you have an XML Schema or DTD associated to your XML document?
Does the fact that Oxygen adds indentation and extra line breaks inside it affect the way in which you are processing the XML document later one?


Regards,
Radu

Re: How can I prevent whitespace between elements when inserting via an action in Oxygen Author Mode?

Posted: Mon Apr 12, 2021 3:09 pm
by Jolanda
Hello Radu,

it looks like this, here with the actual element names:

Code: Select all

<app> <note>[TEXT]</note> </app>
In the settings under Editor->Format->XML and Editor->Format altogether I have already set the settings so that the document should not format itself when inserting an element or when switching to text mode. The element <e1> or <app> (https://www.tei-c.org/release/doc/tei-p ... f-app.html) is a block element. If I replace <app> in the Fragment parameter with inline element the spaces also appear. I have included a RelaxNG schema (TEI All). But even if I set the parameters so that the action should not be SchemaAware, the spaces appear.
Does the fact that Oxygen adds indentation and extra line breaks inside it affect the way in which you are processing the XML document later one?
In fact, the whitespace is a problem because the text is edited in Author Mode in a text-scientific way: The text should be reproduced as accurately as possible and the encoding should have no effect on the spaces in the text. Also, when working in the Windows operating system in Author Mode, a paragraph is always visible before and after the <e1> element, something that disappears when the spaces between <e1> and <e2> are deleted. These empty paragraphs in Author Mode disturb the editors because they also appear as if these paragraphs were present in the original text.

Re: How can I prevent whitespace between elements when inserting via an action in Oxygen Author Mode?

Posted: Mon Apr 12, 2021 7:49 pm
by Jolanda
Hi Radu,

I was able to solve it with your hint on serialisation: Under Options > Preferences > Editor > Edit modes > Author > Serialization I had to choose under "Compatibility with other tools" the option "do not break lines, do not indent".

Thank you very much for your help!
Regrads
Jolanda

Re: How can I prevent whitespace between elements when inserting via an action in Oxygen Author Mode?

Posted: Tue Apr 13, 2021 8:22 am
by Radu
Hi Jolanda,

Thanks for the details about the actual TEI P5 element name. I run some more tests on my side, another possibility to achieve what you wanted would have been to go to the Preferences->"Editor / Format / XML" page and add "app" as a space-preserve element or add a custom CSS for the Author visual editor in which you defined app as being white-space:pre.

Regards,
Radu