Customizing the DITA Framework Using a Framework Extension Script
How to customize an existing framework (e.g. DITA) using a framework extension script.
All the validation, editing, and publishing support Oxygen has for a specific XML vocabulary is defined in a framework configuration. Oxygen comes bundled with such frameworks for popular XML vocabularies, such as DITA. A common use case is to make changes to these built-in frameworks, to tailor them according to specific requirements.
- Customize the new document templates.
- Change the Author mode rendering with a new CSS file.
- Remove the Bold, Italic, Underline actions from the Author mode.
- Add the Insert Note action to the toolbar.
Creating the Framework Extension Script
@base
attribute. Also, set a high priority, through the
<priority>
element, to make sure the framework will be
picked in favor of the DITA
one.<script xmlns="http://www.oxygenxml.com/ns/framework/extend"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.oxygenxml.com/ns/framework/extend http://www.oxygenxml.com/ns/framework/extend/frameworkExtensionScript.xsd"
base="DITA">
<name>Custom DITA</name>
<description>A custom DITA framework.</description>
<priority>High</priority>
</script>
Customizing the New Document Templates
The document templates appear when the user invokes the New... action. To add a new template, you need to do the following:
- In the directory where the script is saved, create a new file (e.g. templates/My custom topic.dita). The content of the file represents the template's content.
- In the script, specify the new template locations by adding this fragment inside
the
<script>
element.<documentTemplates inherit="none"> <addEntry path="${framework}/templates"/> </documentTemplates>
@inherit
attribute is set to not inherit any of the document templates defined in the base framework.Changing the Author Mode Rendering With a New CSS File
The author mode is driven by CSS rules. To add new rules, you need to:
- Create a new CSS file in the directory where the script is saved. Give it
a name (e.g. css/custom.css) and, for example, a rule to make
titles red:
title { color:red; }
- In the script, specify the path to the new CSS by adding this fragment inside
the
<script>
element.<author> <css> <addCss path="${framework}/css/custom.css"/> </css> </author>
Removing the Bold, Italic, Underline Actions From the Author Mode
<script>
element.<author>
<authorActions>
<removeAction id="bold"/>
<removeAction id="italic"/>
<removeAction id="underline"/>
</authorActions>
</author>
Adding the Insert Note Action to the Toolbar
The Insert Node action is already defined in the DITA framework, but it is not present on the toolbar. To add it to the toolbar, you need to:
- Go to Options->Preferences, edit the DITA framework, and search in the Actions tab for the Insert Node action. Make note of its ID.
- Edit the framework extension script and put the action in the toolbar by adding
this fragment inside the
<script>
element.<author> <toolbars> <toolbar> <addAction id="insert.note" anchor="paragraph"/> </toolbar> </toolbars> </author>