note element specializations: Oxygen issues

Post here questions and problems related to editing and publishing DITA content.
gszabo
Posts: 17
Joined: Wed Jan 25, 2023 1:15 am

note element specializations: Oxygen issues

Post by gszabo »

Instead of forcing users to manually set the @type attribute of <note> elements, I specialized elements such as <caution>, <tip>, <warning>, etc. The @type attribute of each specialized elemens has been defined as REQUIRED and allows only the corresponding value: for example, <caution> has @type set to caution:
type (caution) #REQUIRED
However, there are a couple of problems when these elements are inserted via Oxygen:
1. When one of the specialized elements is inserted, the @type attribute is added, but set to an empty value, & thus causes a validation error:
<!ENTITY % caution.attributes
"type (caution) #REQUIRED
spectitle CDATA #IMPLIED
othertype CDATA #IMPLIED
%univ-atts;
outputclass CDATA #IMPLIED">

2. When one of the specialized note elements is inserted in Author mode, a dropdown containing the <note> element's allowed @type values is displayed, which then allows users to specify invalid values, such as setting the <caution> element's @type to "warning". A screenshot is attached that shows both the empty @type and Oxygen allowing invalid values to be selected. .
Oxygen_ignores_DTD.png

How do I get get Oxygen to respect the DTD, instead of introducing validation errors. In other words, is there a setting or preferences that forces Oxygen to automatically add required attribute values when an element is inserted, and to not display the dropdown that allows users to select invalid values?

Thank you for your help.
You do not have the required permissions to view the files attached to this post.
chrispitude
Posts: 922
Joined: Thu May 02, 2019 2:32 pm

Re: note element specializations: Oxygen issues

Post by chrispitude »

I wonder if a cc_config_ext.xml file provides any controls that would be useful?

Configuring the Proposals for Elements and Attributes

Configuring the Proposals for Attribute and Element Values

For example, something like:

Code: Select all

<elementProposals path="caution">
    <insertAttribute name="type" value="caution"/>
</elementProposals>
If you decide to use this mechanism, I suggest using a cc_config_ext.xml file to extend/override the default proposals, instead of using a cc_config.xml file (no "_ext") which disables all the default proposals.

Edit: You could also implement custom Oxygen editor insertion actions that inserts XML fragments with the attribute predefined, but I would definitely try to avoid this if possible.
gszabo
Posts: 17
Joined: Wed Jan 25, 2023 1:15 am

Re: note element specializations: Oxygen issues

Post by gszabo »

Thanks chrispitude.
I ended up finding an alternate way to handle these issues:

1. To get Oxygen to insert the correct @type attributes, I changed the DTD definitions of @type to #FIXED, and thus didn't need to use the cc_config_ext.xml approach:

Code: Select all

type CDATA #FIXED 'caution'
2. The following css gets rid of the widget/dropdown:

Code: Select all

      *[class ~= "topic/note"]:before(3),
     *[class ~= "topic/note"]:before(2) {
           display: none;
     }
Last edited by gszabo on Tue May 09, 2023 10:52 pm, edited 1 time in total.
Radu
Posts: 9446
Joined: Fri Jul 09, 2004 5:18 pm

Re: note element specializations: Oxygen issues

Post by Radu »

Hi,
I approve with both changes you made.
The CSS changes probably removed that drop down button and the DTD change signaled to Oxygen that the attribute has a default fixed attribute and it no longer needs to be added to an inserted element as its default fixed value comes from the DTD.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply