Page 1 of 1

note element specializations: Oxygen issues

Posted: Tue May 09, 2023 3:42 pm
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.

Re: note element specializations: Oxygen issues

Posted: Tue May 09, 2023 3:53 pm
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.

Re: note element specializations: Oxygen issues

Posted: Tue May 09, 2023 6:17 pm
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;
     }

Re: note element specializations: Oxygen issues

Posted: Wed May 10, 2023 8:52 am
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