How to modify built-in code fragments?

Post here questions and problems related to editing and publishing DITA content.
Frank Ralf
Posts: 460
Joined: Thu Jan 23, 2014 2:29 pm
Location: Hamburg
Contact:

How to modify built-in code fragments?

Post by Frank Ralf »

Hi,

When adding a new <hazardstatement> element, Oxygen automatically adds the sub-structure like so:

Code: Select all

<hazardstatement>
        <messagepanel>
           <typeofhazard></typeofhazard>
           <howtoavoid></howtoavoid>
        </messagepanel>
 </hazardstatement>
How/Where can I modify that code fragment to also include a <consequence> element?

Best regards,
Frank
Frank Ralf
parson AG
www.parson-europe.com
Radu
Posts: 9059
Joined: Fri Jul 09, 2004 5:18 pm

Re: How to modify built-in code fragments?

Post by Radu »

Hi Frank,
One option if you have a DITA DTD/RNG specialization would be to modify the schema and declare "consequence" as a required child of hazardstatement. Probably now it is declared as an optional child.
Another option would be to have a custom content completion configuration file:
https://www.oxygenxml.com/doc/versions/ ... ually.html
and declare inside it:

Code: Select all

<elementProposals path="hazardstatement" insertElements="hazardstatement consequence"/>
and yet another possibility, replace in the content completion window the "hazardstatement" element with a custom Author action:
https://blog.oxygenxml.com/topics/custo ... etion.html
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Frank Ralf
Posts: 460
Joined: Thu Jan 23, 2014 2:29 pm
Location: Hamburg
Contact:

Re: How to modify built-in code fragments?

Post by Frank Ralf »

Hi Radu,

Thanks for the pointers. We don't want to touch the schema because even if we highly recommend to use the "consequence" element, we don't want to make it required. So we will go one of the other routes. I had already thought about the "Author Action" way but had forgotten about the custom content completion configuration file.

Best regards,
Frank
Frank Ralf
parson AG
www.parson-europe.com
Frank Ralf
Posts: 460
Joined: Thu Jan 23, 2014 2:29 pm
Location: Hamburg
Contact:

Re: How to modify built-in code fragments?

Post by Frank Ralf »

Hi,

I created a custom configuration file cc_config_ext.xml as described in https://www.oxygenxml.com/doc/versions/ ... ually.html with the following content, which does the trick:

Code: Select all

<elementProposals path="messagepanel" insertElements="typeofhazard consequence howtoavoid" />
This creates the desired structure:

Code: Select all

<hazardstatement>
    <messagepanel>
        <typeofhazard />
        <consequence />
        <howtoavoid />
    </messagepanel>
</hazardstatement>
Thanks again for your kind help!
Frank
Frank Ralf
parson AG
www.parson-europe.com
Post Reply