How to change what is inserted for an element

Posts: 26
Joined: Thu Apr 26, 2012 5:36 pm

How to change what is inserted for an element

Post by mattwolfe » Thu Apr 26, 2012 5:42 pm

Hi all. Sorry if this is in the incorrect forum.

In our OT implementation, we need to have a <p> element inside a <stepresult> element (and some others, but I'll stick to <stepresult> for this question). Right now, when I insert a <stepresult>, I have to remember to also insert a <p> inside the <stepresult>. Is there a way to configure Oxygen so the <p> is automatically inserted along with the <stepresult>?

Incidentally, I do have a code template defined that will insert this, but there's no validation on the code template (meaning, I can pick it no matter where the cursor is located and no matter what type of topic I'm editing). Ideally, I would like to change the default behavior of inserting a <stepresult> so it includes a <p> element, thus using validation.

Is this possible? Thanks!

Posts: 221
Joined: Wed May 20, 2009 2:40 pm

Re: How to change what is inserted for an element

Post by mihaela » Fri Apr 27, 2012 12:39 pm


This type of restrictions must be imposed from schema associated with document type (in your case DITA).
For example, the DITA-OT schema specifies that the <p> element is optional in a <stepresult> context (see [DITA_OT_dir]/dtd/technicalContent/dtd/task.mod). So, to change the type of p child from optional to required you have to change the stepresult content declaration from:

Code: Select all

<!ENTITY % stepresult.content
into something like:

Code: Select all

<!ENTITY % stepresult.content
"(p, (
After you make this modification, the <p> child will be automatically inserted in <stepresult> by the content completion in oXygen editor, in a DITA file.

Please note that changing directly the DITA-OT schema is not the best way to work because it is possible to loose this modifications on a future DITA-OT update. The best way to do is to create your DITA specialization that overrides the default element definition for <stepresult> from the DITA-OT.
You can read more about DITA Specialization Support on our online documentation: ... pport.html

Another possibility to impose the <p> child when inserting the <stepresult> element is to use the Author SDK: ... horing_SDK
In this case, you can use a ro.sync.ecss.extensions.api.AuthorDocumentFilter to change the fragments that are inserted in the document.
Here is the javadoc for this API: ... ilter.html
If you choose this way we can give you more details.

Mihaela Calotescu

Posts: 26
Joined: Thu Apr 26, 2012 5:36 pm

Re: How to change what is inserted for an element

Post by mattwolfe » Fri Apr 27, 2012 6:41 pm

Thanks for you reply. That's a lot to digest. :-) I'll go over the information and see what I can do. Thanks!

Posts: 7019
Joined: Fri Jul 09, 2004 5:18 pm

Re: How to change what is inserted for an element

Post by Radu » Mon Apr 30, 2012 12:12 pm

Hi Matt,

Indeed a code template gets presented in the content completion list no matter in which element the caret is placed.

There is another workaround which could work for you:
In the Document Type Association preferences page, edit the DITA document type.
In the Author tab you can define a new action for inserting a

Code: Select all

fragment and set for the action an XPath expression for the places where you want the action to be active.
As an example you can look at the already defined insert.topic action.

Then in the Content Completion tab you have the possibility to add that new defined action to the content completion window and even to remove the "stepresult" entry provided by Oxygen by looking in the DTDs from the content completion window.

The content completion window will only show added actions if the XPath expression configured when editing the action is fulfilled.

Radu Coravu
<oXygen/> XML Editor

Post Reply