Is there an Oxygen setting that automatically removes empty attributes from DITA topics?

Post here questions and problems related to editing and publishing DITA content.
gchale3rd
Posts: 20
Joined: Wed Jan 04, 2017 3:48 pm

Is there an Oxygen setting that automatically removes empty attributes from DITA topics?

Post by gchale3rd »

Background
We create release notes for internal and external audiences, and we use a template to create our release notes topics. The template has a prompt that asks the writer if the topic is only for internal audiences. If the writer selects Yes, the topic's audience attribute is set to internal. If the writer selects No, the topic's audience attribute is set to a null value (Empty).

All topics in the external release notes are also included in the internal release notes. Topics where audience = internal are only included in the internal release notes. We use separate transformation scenarios to generate the release notes for external or internal audiences. Each transformation scenario has its own DITAVAL file. One DITAVAL file excludes topics where audience = internal, and the other DITAVAL file includes topics where audience = internal. Consequently, we do not set a value for the audience attribute if a writer selects No at the prompt.

We also set another attribute at the topic root level, but we do that manually instead of automatically via a prompt. In topics where the audience attribute = Empty, when some writers set the additional attribute, Oxygen automatically removes the null audience attribute. That's not the case for all of the writers. When some writers set the additional attribute, the null audience attribute remains in the topic.

Question
Is there a setting in Oxygen that causes Oxygen to remove the null audience attribute when a writer sets the value for the additional attribute?
Radu
Posts: 8956
Joined: Fri Jul 09, 2004 5:18 pm

Re: Is there an Oxygen setting that automatically removes empty attributes from DITA topics?

Post by Radu »

Hi,

I do not quite understand what you mean by "null audience attribute".
Do you mean something like this?

Code: Select all

<p audience="">...</p>
That new file template with a prompt that you mentioned, was it a customization that you added to Oxygen?
We do not have a setting in Oxygen to automatically remove empty attributes when editing.
In the Oxygen main menu Tools=>XML Refactoring dialog we have a "Delete attribute" refactoring action which you could try to apply to all element xpaths like "*[@audience=""]" and choose to remove from them the "audience" attribute. Such refactoring actions have previews and can be applied on multiple files.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
gchale3rd
Posts: 20
Joined: Wed Jan 04, 2017 3:48 pm

Re: Is there an Oxygen setting that automatically removes empty attributes from DITA topics?

Post by gchale3rd »

Hello Radu. Let me see if I can explain this better. I have attached a flowchart of the process, and the numbers on the flowchart correspond to the numbered items below.
oxygen_topic_flow.png
oxygen_topic_flow.png (237.46 KiB) Viewed 975 times
  1. When we create a topic using the template, a prompt displays asking the writer to select an audience: External or Internal. A value corresponding to the prompt selection is inserted in the av-audience attribute of the <concept> element.
  2. If a writer selects External at the prompt, the av-audience attribute shows as Empty. We purposely do not set a value for the av-audience attribute when a writer selects External. The XML looks like this (there is a space in the av-audience attribute):

    Code: Select all

    <concept id="c_oxygen_test" av-audience=" " av-env=" ">
  3. For this particular type of topic, we have to set a value in the av-region attribute of the <concept> element. We do this manually via the Edit Profiling Attributes window instead of via a prompt (there are too many region values to include in a prompt).
  4. When most of the writers set the value for the av-region attribute, the Empty av-audience attribute value is automatically removed from the topic (which is ideal). However, when some of the writers set the value for the av-region attribute, the Empty av-audience attribute value remains in the topic, forcing the writers to manually remove the attribute value.
Do you have any ideas why the Empty av-audience value is automatically removed for some writers but not for others when we set the av-region attribute? I was wondering if there is a setting in Oxygen that does this.
chrispitude
Posts: 907
Joined: Thu May 02, 2019 2:32 pm

Re: Is there an Oxygen setting that automatically removes empty attributes from DITA topics?

Post by chrispitude »

Hi gchale3rd,

I haven't seen that "Choose the topic audience" before; it might be something custom configured in your environment.

What specific action do you perform in Oxygen to show this dialog?

- Chris
Radu
Posts: 8956
Joined: Fri Jul 09, 2004 5:18 pm

Re: Is there an Oxygen setting that automatically removes empty attributes from DITA topics?

Post by Radu »

Hi,

You seem to have some kind of Oxygen framework customization to show that input dialog allowing people to choose the topic audience. We do not know about how your customization works, Oxygen has lots of Java APIs which could be used to make changes to attribute, we also have some $ask editor variables which expand to input dialogs.
Ideally in such cases you should ask the persons who created the customization as we do not offer technical support in debugging customizations.
Oxygen itself does not have a builtin setting to automatically remove empty attributes.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
chrispitude
Posts: 907
Joined: Thu May 02, 2019 2:32 pm

Re: Is there an Oxygen setting that automatically removes empty attributes from DITA topics?

Post by chrispitude »

Hi gchale3rd,

For each of these attributes, you should be able to use Oxygen's built-in Delete attribute refactoring operation as follows:

image.png
image.png (13.81 KiB) Viewed 928 times

where attribute-name is the name of the attribute to process here:

Code: Select all

Element: *[@attribute-name = ' ']
Attribute: attribute-name
You can Preview the refactoring operation to make sure it is doing what you want.
gchale3rd
Posts: 20
Joined: Wed Jan 04, 2017 3:48 pm

Re: Is there an Oxygen setting that automatically removes empty attributes from DITA topics?

Post by gchale3rd »

The prompt asking the writer to select an audience is achieved by the following Oxygen editor variable in the topic's root element:

Code: Select all

<concept id="${cfn}" av-audience="${ask('Choose the topic audience:', radio, (' ':'External - Include topic in release blog, communication, and presentation.';'pep_internal':'Internal - Include topic only in release presentation.'), )}">
The prompt inserts a value in the av-audience attribute.
  • If a writer selects the External radio button, Oxygen inserts a space in the av-audience attribute. We do not want a value set for the av-audience attribute when the audience is External. Using a space was our best idea as a null value.
  • If a writer selects the Internal radio button, Oxygen inserts pep_internal in the av-audience attribute.
I understand how to remove an attribute using Oxygen's Delete attribute refactoring operation. What I don't understand are the different results that occur when writers set another attribute value on a topic where the av-audience attribute contains a space.
  • When some writers set another attribute value on a topic where the av-audience attribute contains a space, Oxygen automatically removes the av-audience attribute from the topic. This is the ideal result.
  • When some writers set another attribute value on a topic where the av-audience attribute contains a space, Oxygen does not automatically remove the av-audience attribute from the topic.
This is not a big issue. We were just curious why the av-audience attribute containing a space is automatically removed for some writers but not for others. Thank you for your feedback.
Radu
Posts: 8956
Joined: Fri Jul 09, 2004 5:18 pm

Re: Is there an Oxygen setting that automatically removes empty attributes from DITA topics?

Post by Radu »

Hi,

Please see some answers below:
If a writer selects the External radio button, Oxygen inserts a space in the av-audience attribute. We do not want a value set for the av-audience attribute when the audience is External. Using a space was our best idea as a null value.
I understand, editor variables are just some macros which get expanded in place, they cannot state that an entire attribute which has a value containing the editor variable should be deleted, as you would want. We have Java APIs which would allow a plugin to control more precisely what a new file template should contain but most people use ask editor variables because they are easier to use. Unfortunately being just macros which get expanded in place, they have their limitations.
When some writers set another attribute value on a topic where the av-audience attribute contains a space, Oxygen automatically removes the av-audience attribute from the topic. This is the ideal result.
Can you reproduce this behavior on your side? If not, maybe it's possible the writers were mistaken.
As far as I know when editing an attribute in Oxygen, Oxygen should not by default remove another one. Unless there is some kind of plugin or framework configuration which has been set up to do that.
When some writers set another attribute value on a topic where the av-audience attribute contains a space, Oxygen does not automatically remove the av-audience attribute from the topic.
This I would expect to be like this. At least if no extra plugins or frameworks which would add some custom behavior of removing an attribute when another one is modified would be installed.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
gchale3rd
Posts: 20
Joined: Wed Jan 04, 2017 3:48 pm

Re: Is there an Oxygen setting that automatically removes empty attributes from DITA topics?

Post by gchale3rd »

I think I figured this out Radu. If an attribute shows as Empty or containing a space (see highlighted area in attached image).
oxygen_empty_attribute.png
oxygen_empty_attribute.png (51.26 KiB) Viewed 857 times
  • Oxygen automatically removes the attributes when the writer sets an attribute value in the Edit Profile Settings Window.
  • Oxygen does not automatically remove the Empty attribute when the writer sets an attribute value in the Attributes view. It does, however, automatically remove the attribute if it contains a space.
I'm not sure why the av-audience attribute shows as Empty while the av-env attribute shows as a space (as shown in the attached example). In the two prompts I use to set the attribute values, each one contains a radio button that uses a space for the real value. When I look at the resulting XML for both attributes, the attribute value is a space. I'm guessing it has something to do with how the attributes are defined in the subject scheme map.

In your reply, you mentioned some Java APIs which would allow a plugin to control more precisely what a new file template should contain. Can you point me to those APIs?
Radu
Posts: 8956
Joined: Fri Jul 09, 2004 5:18 pm

Re: Is there an Oxygen setting that automatically removes empty attributes from DITA topics?

Post by Radu »

Hi,

Please see some remarks below:
Oxygen automatically removes the attributes when the writer sets an attribute value in the Edit Profile Settings Window.
Oh, I can also reproduce this. So if I use on that element the "Edit Profiling Attributes" dialog on another profiling attribute, the profiling attribute which has initially spaces in its value no longer gets serialized when the "Edit Profiling Attributes" dialog is closed. Which is not so bad in your case.
Oxygen does not automatically remove the Empty attribute when the writer sets an attribute value in the Attributes view.
Right, if for example I set a value for attribute "x" in the Attributes view, it does not influence the value for attribute "y", no matter what that value would be.
It does, however, automatically remove the attribute if it contains a space.
I'm not sure what you mean by that. Can you clarify?
I'm not sure why the av-audience attribute shows as Empty while the av-env attribute shows as a space (as shown in the attached example). In the two prompts I use to set the attribute values, each one contains a radio button that uses a space for the real value. When I look at the resulting XML for both attributes, the attribute value is a space. I'm guessing it has something to do with how the attributes are defined in the subject scheme map.
Yes, it might. That "Empty" is a form control which when pressed allows you to choose values for the attribute. Possibly for the other attribute Oxygen does not have profiling values configured...
In your reply, you mentioned some Java APIs which would allow a plugin to control more precisely what a new file template should contain. Can you point me to those APIs?
So your current new file template contains something like:

Code: Select all

<concept av-audience="${ask(.....)}">
The ask editor variable controls the attribute value but the "av-audience" will still be present in the XML file no matter to what value the "ask" editor variable gets expanded.
Using our APIs you could implement your own editor variable, maybe something like:

Code: Select all

<concept ${provide_attribute_and_value(av-audience)}>
An Oxygen plugin allows you to add a custom editor variables resolver:
https://www.oxygenxml.com/InstData/Edit ... sResolver-
which would allow you to take full control over how an editor variable should be expanded, for example to implement your own Java Swing dialog for showing the possible values.
A sample Maven-based Oxygen plugin of type workspace access can be found here:
https://github.com/oxygenxml/sample-plu ... ace-access
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
gchale3rd
Posts: 20
Joined: Wed Jan 04, 2017 3:48 pm

Re: Is there an Oxygen setting that automatically removes empty attributes from DITA topics?

Post by gchale3rd »

@chrispitude
Thank you for the example you included in your reply.
I was trying (unsuccessfully) to run the Delete Attribute refactoring operation to remove the same attribute from several different elements. I was going to post a question on the forum, but I fortunately read this post first. From the example you provided, I figured out I could use *[@av-env='non_prod'] as the value in the Element field in XML Refactoring window. I appreciate the help.
Post Reply